octopi 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
-
3
- class AuthenticatedTest < Test::Unit::TestCase
4
- include Octopi
5
-
6
- def setup
7
- fake_everything
8
- @user = User.find("fcoury")
9
- end
10
-
11
- context "following" do
12
-
13
- should "not be able to follow anyone if not authenticated" do
14
- exception = assert_raise AuthenticationRequired do
15
- Api.me.follow!("rails")
16
- end
17
- end
18
-
19
- should "be able to follow a user" do
20
- auth do
21
- assert_not_nil Api.me.follow!("rails")
22
- end
23
- end
24
- end
25
-
26
- context "unfollowing" do
27
-
28
- should "not be able to follow anyone if not authenticated" do
29
- exception = assert_raise AuthenticationRequired do
30
- Api.me.unfollow!("rails")
31
- end
32
- end
33
-
34
- should "be able to follow a user" do
35
- auth do
36
- assert_not_nil Api.me.unfollow!("rails")
37
- end
38
- end
39
- end
40
-
41
- context "keys" do
42
- should "not be able to see keys if not authenticated" do
43
- exception = assert_raise AuthenticationRequired do
44
- Api.me.keys
45
- end
46
-
47
- assert_equal "To view keys, you must be authenticated", exception.message
48
- end
49
-
50
- should "have some keys" do
51
- auth do
52
- keys = Api.me.keys
53
- assert keys.is_a?(KeySet)
54
- assert_equal 2, keys.size
55
- end
56
- end
57
- end
58
- end
@@ -1,39 +0,0 @@
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
@@ -1,20 +0,0 @@
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
@@ -1,23 +0,0 @@
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
-
@@ -1,20 +0,0 @@
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
-
@@ -1,89 +0,0 @@
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
-
@@ -1,39 +0,0 @@
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
-
@@ -1,16 +0,0 @@
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
-
@@ -1,19 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,136 +0,0 @@
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