octopi 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Rakefile +2 -84
- data/examples/authenticated.rb +20 -0
- data/examples/github.yml.example +14 -0
- data/examples/issues.rb +18 -0
- data/examples/overall.rb +50 -0
- data/lib/octopi/version.rb +3 -0
- data/octopi.gemspec +20 -93
- data/real_world_test/commit_test.rb +20 -0
- data/real_world_test/repository_test.rb +19 -0
- data/real_world_test/test_helper.rb +11 -0
- data/test/.gitconfig +3 -0
- data/test/api_test.rb +58 -0
- data/test/authenticated_test.rb +39 -0
- data/test/base_test.rb +20 -0
- data/test/blob_test.rb +23 -0
- data/test/branch_test.rb +20 -0
- data/test/commit_test.rb +89 -0
- data/test/file_object_test.rb +39 -0
- data/test/gist_test.rb +16 -0
- data/test/issue_comment.rb +19 -0
- data/test/issue_set_test.rb +33 -0
- data/test/issue_test.rb +136 -0
- data/test/key_set_test.rb +29 -0
- data/test/key_test.rb +35 -0
- data/test/repository_set_test.rb +23 -0
- data/test/repository_test.rb +164 -0
- data/test/stubs/account +691 -0
- data/test/stubs/blob/fcoury/octopi/plain/f6609209c3ac0badd004512d318bfaa508ea10ae +20 -0
- data/test/stubs/comments/fcoury/octopi/comments +30 -0
- data/test/stubs/comments/fcoury/octopi/comments.atom +48 -0
- data/test/stubs/commits/fcoury/octopi/f6609209c3ac0badd004512d318bfaa508ea10ae +94 -0
- data/test/stubs/commits/fcoury/octopi/lazy +491 -0
- data/test/stubs/commits/fcoury/octopi/master +477 -0
- data/test/stubs/commits/fcoury/octopi/octopi.rb +818 -0
- data/test/stubs/commits/fcoury/rboard/master +437 -0
- data/test/stubs/dashboard +231 -0
- data/test/stubs/errors/repository/not_found +16 -0
- data/test/stubs/gists/159579 +18 -0
- data/test/stubs/issues/fcoury/octopi/27 +42 -0
- data/test/stubs/issues/fcoury/octopi/27-reopened +27 -0
- data/test/stubs/issues/fcoury/octopi/28 +27 -0
- data/test/stubs/issues/fcoury/octopi/28-closed +27 -0
- data/test/stubs/issues/fcoury/octopi/28-edited +27 -0
- data/test/stubs/issues/fcoury/octopi/closed +175 -0
- data/test/stubs/issues/fcoury/octopi/comment/28-comment +15 -0
- data/test/stubs/issues/fcoury/octopi/labels/28-maybe-two-point-oh +16 -0
- data/test/stubs/issues/fcoury/octopi/labels/28-one-point-oh +16 -0
- data/test/stubs/issues/fcoury/octopi/labels/28-remove-maybe-two-point-oh +14 -0
- data/test/stubs/issues/fcoury/octopi/labels/28-remove-one-point-oh +15 -0
- data/test/stubs/issues/fcoury/octopi/new +27 -0
- data/test/stubs/issues/fcoury/octopi/open +329 -0
- data/test/stubs/issues/fcoury/octopi/search +139 -0
- data/test/stubs/login +157 -0
- data/test/stubs/repos/fcoury/octopi/branches +18 -0
- data/test/stubs/repos/fcoury/octopi/collaborators +16 -0
- data/test/stubs/repos/fcoury/octopi/delete-token +13 -0
- data/test/stubs/repos/fcoury/octopi/languages +16 -0
- data/test/stubs/repos/fcoury/octopi/main +12 -0
- data/test/stubs/repos/fcoury/octopi/master +24 -0
- data/test/stubs/repos/fcoury/octopi/tags +23 -0
- data/test/stubs/repos/fcoury/octopus/main +24 -0
- data/test/stubs/repos/fcoury/rboard/main +12 -0
- data/test/stubs/repos/fcoury/rboard/master +24 -0
- data/test/stubs/repos/search +238 -0
- data/test/stubs/repos/show/fcoury +463 -0
- data/test/stubs/repos/show/fcoury-private +454 -0
- data/test/stubs/tree/fcoury/octopi/f6609209c3ac0badd004512d318bfaa508ea10ae +54 -0
- data/test/stubs/users/Caged +26 -0
- data/test/stubs/users/FooBarWidget +26 -0
- data/test/stubs/users/aslakhellesoy +26 -0
- data/test/stubs/users/augustl +26 -0
- data/test/stubs/users/bcalloway +26 -0
- data/test/stubs/users/benaskins +26 -0
- data/test/stubs/users/benhoskings +26 -0
- data/test/stubs/users/bjeanes +27 -0
- data/test/stubs/users/cldwalker +26 -0
- data/test/stubs/users/danlucraft +26 -0
- data/test/stubs/users/dchelimsky +26 -0
- data/test/stubs/users/dcrec1 +26 -0
- data/test/stubs/users/defunkt +26 -0
- data/test/stubs/users/derencius +26 -0
- data/test/stubs/users/diy +21 -0
- data/test/stubs/users/documentcloud +26 -0
- data/test/stubs/users/drnic +26 -0
- data/test/stubs/users/dustin +26 -0
- data/test/stubs/users/eladmeidar +26 -0
- data/test/stubs/users/elliottcable +26 -0
- data/test/stubs/users/entp +26 -0
- data/test/stubs/users/fcoury +26 -0
- data/test/stubs/users/fcoury-private +36 -0
- data/test/stubs/users/follow +15 -0
- data/test/stubs/users/follow-rails +15 -0
- data/test/stubs/users/followers +24 -0
- data/test/stubs/users/following +28 -0
- data/test/stubs/users/giraffesoft +26 -0
- data/test/stubs/users/gwoliveira +26 -0
- data/test/stubs/users/hashrocket +26 -0
- data/test/stubs/users/hcatlin +26 -0
- data/test/stubs/users/jamis +26 -0
- data/test/stubs/users/jnicklas +26 -0
- data/test/stubs/users/jnunemaker +26 -0
- data/test/stubs/users/jruby +21 -0
- data/test/stubs/users/kballard +26 -0
- data/test/stubs/users/kchris +26 -0
- data/test/stubs/users/key-added +20 -0
- data/test/stubs/users/key-removed +17 -0
- data/test/stubs/users/keys +21 -0
- data/test/stubs/users/knewter +26 -0
- data/test/stubs/users/lachie +26 -0
- data/test/stubs/users/lachlanhardy +26 -0
- data/test/stubs/users/lenary +26 -0
- data/test/stubs/users/lifo +26 -0
- data/test/stubs/users/maccman +26 -0
- data/test/stubs/users/markgandolfo +26 -0
- data/test/stubs/users/mbleigh +26 -0
- data/test/stubs/users/mhodgson +26 -0
- data/test/stubs/users/mocra +26 -0
- data/test/stubs/users/mojombo +26 -0
- data/test/stubs/users/newbamboo +26 -0
- data/test/stubs/users/notahat +26 -0
- data/test/stubs/users/opscode +26 -0
- data/test/stubs/users/paulorv +26 -0
- data/test/stubs/users/pvande +21 -0
- data/test/stubs/users/rack +26 -0
- data/test/stubs/users/radar +26 -0
- data/test/stubs/users/rails +26 -0
- data/test/stubs/users/railscampau +21 -0
- data/test/stubs/users/redinger +26 -0
- data/test/stubs/users/remi +26 -0
- data/test/stubs/users/search-radar +27 -0
- data/test/stubs/users/shanesveller +26 -0
- data/test/stubs/users/shuber +26 -0
- data/test/stubs/users/softprops +26 -0
- data/test/stubs/users/superfeedr +26 -0
- data/test/stubs/users/svenfuchs +26 -0
- data/test/stubs/users/taylorrf +26 -0
- data/test/stubs/users/technoweenie +26 -0
- data/test/stubs/users/tgraham +26 -0
- data/test/stubs/users/thoughtbot +26 -0
- data/test/stubs/users/tmm1 +26 -0
- data/test/stubs/users/tobi +26 -0
- data/test/stubs/users/tpope +26 -0
- data/test/stubs/users/unfollow-rails +14 -0
- data/test/stubs/users/watched-repos +1668 -0
- data/test/stubs/users/webbynode +26 -0
- data/test/stubs/users/wvanbergen +26 -0
- data/test/stubs/users/wycats +26 -0
- data/test/tag_test.rb +20 -0
- data/test/test_helper.rb +251 -0
- data/test/user_test.rb +97 -0
- data/test_auth.rb +5 -0
- metadata +359 -73
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class AuthenticatedTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
def setup
|
6
|
+
fake_everything
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Authenticating" do
|
10
|
+
should "be possible with username and password" do
|
11
|
+
authenticated_with(:login => "fcoury", :password => "yruocf") do
|
12
|
+
assert_equal "8f700e0d7747826f3e56ee13651414bd", Api.api.token
|
13
|
+
assert_not_nil User.find("fcoury")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
should "be possible with username and token" do
|
18
|
+
auth do
|
19
|
+
assert_not_nil User.find("fcoury")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
should "be possible using the .gitconfig" do
|
24
|
+
authenticated do
|
25
|
+
assert_not_nil User.find("fcoury")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
#
|
29
|
+
# should "be denied access when specifying an invalid token and login combination" do
|
30
|
+
# FakeWeb.clean_registry
|
31
|
+
# FakeWeb.register_uri(:get, "http://github.com/api/v2/yaml/user/show/fcoury", :status => ["404", "Not Found"])
|
32
|
+
# assert_raise InvalidLogin do
|
33
|
+
# authenticated_with :login => "fcoury", :token => "ba7bf2d7f0ebc073d3874dda887b18ae" do
|
34
|
+
# # Just blank will do us fine.
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
end
|
39
|
+
end
|
data/test/base_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
class SparseUser < Octopi::Base
|
5
|
+
include Octopi::Resource
|
6
|
+
|
7
|
+
attr_accessor :some_attribute
|
8
|
+
|
9
|
+
find_path "/user/search/:query"
|
10
|
+
resource_path "/user/show/:id"
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
fake_everything
|
15
|
+
end
|
16
|
+
|
17
|
+
should "not raise an error if it doesn't know about the attributes that GitHub API provides" do
|
18
|
+
assert_nothing_raised { SparseUser.find("radar") }
|
19
|
+
end
|
20
|
+
end
|
data/test/blob_test.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class BlobTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
end
|
9
|
+
|
10
|
+
context Blob do
|
11
|
+
should "find a blob" do
|
12
|
+
blob = Blob.find(:user => "fcoury", :repo => "octopi", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
13
|
+
assert_not_nil blob
|
14
|
+
assert blob.is_a?(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Can't grab real data for this yet, Github is throwing a 500 on this request.
|
18
|
+
# should "find a file for a blob" do
|
19
|
+
# assert_not_nil Blob.find(:user => "fcoury", :repo => "octopi", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae", :path => "lib/octopi.rb")
|
20
|
+
# end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/test/branch_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class BranchTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
end
|
9
|
+
|
10
|
+
context Branch do
|
11
|
+
should "Find all branches for a repository" do
|
12
|
+
assert_not_nil Branch.all(:user => "fcoury", :name => "octopi")
|
13
|
+
end
|
14
|
+
|
15
|
+
should "Be able to find a specific branch" do
|
16
|
+
assert_not_nil Branch.all(:user => "fcoury", :name => "octopi").find("lazy")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/test/commit_test.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class CommitTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
@user = User.find("fcoury")
|
9
|
+
@repo = @user.repository(:name => "octopi")
|
10
|
+
end
|
11
|
+
|
12
|
+
context Commit do
|
13
|
+
context "finding all commits" do
|
14
|
+
should "by strings" do
|
15
|
+
commits = Commit.find_all(:user => "fcoury", :repository => "octopi")
|
16
|
+
assert_not_nil commits
|
17
|
+
assert_equal 30, commits.size
|
18
|
+
assert_not_nil commits.first.repository
|
19
|
+
end
|
20
|
+
|
21
|
+
should "by objects" do
|
22
|
+
commits = Commit.find_all(:user => @user, :repository => @repo)
|
23
|
+
assert_not_nil commits
|
24
|
+
assert_equal 30, commits.size
|
25
|
+
end
|
26
|
+
|
27
|
+
should "second page of commits" do
|
28
|
+
commits = Commit.find_all(:user => "fcoury", :repository => "octopi", :page => 2)
|
29
|
+
assert_not_nil commits
|
30
|
+
assert_equal 30, commits.size
|
31
|
+
assert_not_nil commits.first.repository
|
32
|
+
end
|
33
|
+
|
34
|
+
should "be able to specify a branch" do
|
35
|
+
commits = Commit.find_all(:user => "fcoury", :repository => "octopi", :branch => "lazy")
|
36
|
+
assert_not_nil commits
|
37
|
+
assert_equal 30, commits.size
|
38
|
+
end
|
39
|
+
|
40
|
+
# Tests issue #28
|
41
|
+
should "be able to find commits in a private repository" do
|
42
|
+
auth do
|
43
|
+
commits = Commit.find_all(:user => "fcoury", :repository => "rboard")
|
44
|
+
end
|
45
|
+
assert_not_nil commits
|
46
|
+
assert_equal 22, commits.size
|
47
|
+
end
|
48
|
+
|
49
|
+
should "be able to find commits for a particular file" do
|
50
|
+
commits = Commit.find_all(:user => "fcoury", :repository => "octopi", :path => "lib/octopi.rb")
|
51
|
+
assert_not_nil commits
|
52
|
+
assert_equal 44, commits.size
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "finding a single commit" do
|
57
|
+
should "by strings" do
|
58
|
+
commit = Commit.find(:name => "octopi", :user => "fcoury", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
59
|
+
assert_not_nil commit
|
60
|
+
end
|
61
|
+
|
62
|
+
should "by objects" do
|
63
|
+
commit = Commit.find(:name => "octopi", :user => "fcoury", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
64
|
+
assert_not_nil commit
|
65
|
+
end
|
66
|
+
|
67
|
+
should "be able to specify a branch" do
|
68
|
+
commit = Commit.find(:name => "octopi", :user => "fcoury", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae", :branch => "lazy")
|
69
|
+
assert_not_nil commit
|
70
|
+
end
|
71
|
+
|
72
|
+
should "raise an error if not found" do
|
73
|
+
exception = assert_raise Octopi::NotFound do
|
74
|
+
Commit.find(:name => "octopi", :user => "fcoury", :sha => "nothere")
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_equal "The Commit you were looking for could not be found, or is private.", exception.message
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "identifying a repository" do
|
82
|
+
should "be possible" do
|
83
|
+
commit = Commit.find(:name => "octopi", :user => "fcoury", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
84
|
+
assert_equal "fcoury/octopi/f6609209c3ac0badd004512d318bfaa508ea10ae", commit.repo_identifier
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class FileObjectTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
@user = User.find("fcoury")
|
9
|
+
@repo = @user.repositories.find("octopi")
|
10
|
+
end
|
11
|
+
|
12
|
+
context "finding" do
|
13
|
+
context "with strings" do
|
14
|
+
should "work" do
|
15
|
+
FileObject.find(:user => "fcoury", :repository => "octopi", :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with objects" do
|
20
|
+
should "work" do
|
21
|
+
FileObject.find(:user => @user, :repository => @repo, :sha => "f6609209c3ac0badd004512d318bfaa508ea10ae")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "invalid sha" do
|
26
|
+
should "not work" do
|
27
|
+
# sha below is "ryan"
|
28
|
+
exception = assert_raise NotFound do
|
29
|
+
FileObject.find(:user => @user, :repository => @repo, :sha => "ea3cd978650417470535f3a4725b6b5042a6ab59")
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_equal "The FileObject you were looking for could not be found, or is private.", exception.message
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
data/test/gist_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class GistTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
end
|
9
|
+
|
10
|
+
context Gist do
|
11
|
+
should "Find a single gist" do
|
12
|
+
assert_not_nil Gist.find(159579)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class IssueTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
@user = User.find("fcoury")
|
9
|
+
@repo = @user.repository("octopi")
|
10
|
+
end
|
11
|
+
|
12
|
+
context IssueComment do
|
13
|
+
should "be valid" do
|
14
|
+
comment = IssueComment.new({ :comment => "This is a comment", :status => "saved"})
|
15
|
+
assert_not_nil comment.comment
|
16
|
+
assert_not_nil comment.status
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class IssueSetTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
@user = User.find("fcoury")
|
9
|
+
@repo = @user.repository("octopi")
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
context IssueSet do
|
14
|
+
should "be able to find a specific issue" do
|
15
|
+
assert_not_nil @repo.issues.find(28)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "not be able to find an issue that doesn't exist" do
|
19
|
+
exception = assert_raise Octopi::NotFound do
|
20
|
+
@repo.issues.find("not-a-number")
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_equal "The Issue you were looking for could not be found, or is private.", exception.message
|
24
|
+
end
|
25
|
+
|
26
|
+
should "be able to look for an issue" do
|
27
|
+
results = @repo.issues.search(:keyword => "test")
|
28
|
+
assert_not_nil results
|
29
|
+
assert_equal 1, results.size
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/test/issue_test.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class IssueTest < Test::Unit::TestCase
|
4
|
+
include Octopi
|
5
|
+
|
6
|
+
def setup
|
7
|
+
fake_everything
|
8
|
+
@user = User.find("fcoury")
|
9
|
+
@repo = @user.repository("octopi")
|
10
|
+
@issue = Issue.find(:user => @user, :repo => @repo, :number => 28)
|
11
|
+
@closed = Issue.find(:user => @user, :repo => @repo, :number => 27)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
context Issue do
|
16
|
+
context "finding all the issues" do
|
17
|
+
should "using objects" do
|
18
|
+
issues = Issue.find_all(:user => @user, :repo => @repo)
|
19
|
+
assert_not_nil issues
|
20
|
+
assert_equal 30, issues.size
|
21
|
+
end
|
22
|
+
|
23
|
+
should "using strings" do
|
24
|
+
issues = Issue.find_all(:user => "fcoury", :repo => "octopi")
|
25
|
+
assert_not_nil issues
|
26
|
+
assert_equal 30, issues.size
|
27
|
+
end
|
28
|
+
|
29
|
+
should "all closed issues" do
|
30
|
+
issues = Issue.find_all(:user => @user, :repo => @repo, :state => "closed")
|
31
|
+
assert_not_nil issues
|
32
|
+
assert_equal 9, issues.size
|
33
|
+
end
|
34
|
+
|
35
|
+
should "all open issues" do
|
36
|
+
issues = Issue.find_all(:user => @user, :repo => @repo, :state => "open")
|
37
|
+
assert_not_nil issues
|
38
|
+
assert_equal 21, issues.size
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "finding a single issue" do
|
43
|
+
should "work" do
|
44
|
+
issue = Issue.find(:user => @user, :repo => @repo, :number => 28)
|
45
|
+
assert_not_nil issue
|
46
|
+
assert_not_nil issue.body
|
47
|
+
end
|
48
|
+
|
49
|
+
should "not work, if issue doesn't exist" do
|
50
|
+
exception = assert_raise NotFound do
|
51
|
+
Issue.find(:user => @user, :repo => @repo, :number => "not-a-number")
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal "The Issue you were looking for could not be found, or is private.", exception.message
|
55
|
+
end
|
56
|
+
|
57
|
+
should "be able to look for an issue" do
|
58
|
+
results = Issue.search(:user => @user, :repo => @repo, :keyword => "test")
|
59
|
+
assert_not_nil results
|
60
|
+
assert_equal 1, results.size
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "actions" do
|
65
|
+
should "opening an issue" do
|
66
|
+
issue = Issue.open(:user => @user, :repo => @repo, :params => { :title => "something's broken", :body => "something broke" })
|
67
|
+
assert_not_nil issue
|
68
|
+
assert_equal "open", issue.state
|
69
|
+
end
|
70
|
+
|
71
|
+
should "re-opening an issue" do
|
72
|
+
assert_equal "closed", @closed.state
|
73
|
+
@closed.reopen!
|
74
|
+
assert_equal "open", @closed.state
|
75
|
+
end
|
76
|
+
|
77
|
+
should "closing an issue" do
|
78
|
+
assert_equal "open", @issue.state
|
79
|
+
@issue.close!
|
80
|
+
assert_equal "closed", @issue.state
|
81
|
+
end
|
82
|
+
|
83
|
+
should "editing an issue" do
|
84
|
+
@issue.title = 'Testing'
|
85
|
+
@issue.save
|
86
|
+
assert_equal "Testing", @issue.title
|
87
|
+
end
|
88
|
+
|
89
|
+
should "adding a label" do
|
90
|
+
assert @issue.labels.empty?
|
91
|
+
@issue.add_label("one-point-oh")
|
92
|
+
assert !@issue.labels.empty?
|
93
|
+
end
|
94
|
+
|
95
|
+
should "adding multiple labels" do
|
96
|
+
assert @issue.labels.empty?
|
97
|
+
@issue.add_label("one-point-oh", "maybe-two-point-oh")
|
98
|
+
assert !@issue.labels.empty?
|
99
|
+
assert_equal 2, @issue.labels.size
|
100
|
+
end
|
101
|
+
|
102
|
+
should "removing a label" do
|
103
|
+
assert @issue.labels.empty?
|
104
|
+
@issue.add_label("one-point-oh")
|
105
|
+
assert !@issue.labels.empty?
|
106
|
+
@issue.remove_label("one-point-oh")
|
107
|
+
assert @issue.labels.empty?
|
108
|
+
end
|
109
|
+
|
110
|
+
should "removing multiple labels" do
|
111
|
+
assert @issue.labels.empty?
|
112
|
+
@issue.add_label("one-point-oh", "maybe-two-point-oh")
|
113
|
+
assert !@issue.labels.empty?
|
114
|
+
assert_equal 2, @issue.labels.size
|
115
|
+
@issue.remove_label("one-point-oh", "maybe-two-point-oh")
|
116
|
+
assert_equal 0, @issue.labels.size
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
should "be able to comment" do
|
121
|
+
comment = @issue.comment("Yes, it is broken.")
|
122
|
+
assert comment.is_a?(IssueComment)
|
123
|
+
end
|
124
|
+
|
125
|
+
should "be able to get all comments" do
|
126
|
+
first_comment = @issue.comments.first
|
127
|
+
assert first_comment.is_a?(IssueComment)
|
128
|
+
assert_equal "This is fixed in recent release.", first_comment.body
|
129
|
+
assert_equal "radar", first_comment.user
|
130
|
+
assert !first_comment.created_at.blank?
|
131
|
+
assert !first_comment.updated_at.blank?
|
132
|
+
assert !first_comment.gravatar_id.blank?
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|