redbooth-ruby 0.0.5 → 0.1.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -1
- data/README.md +187 -115
- data/lib/redbooth-ruby/client.rb +6 -39
- data/lib/redbooth-ruby/client_operations/perform.rb +93 -0
- data/lib/redbooth-ruby/file.rb +8 -0
- data/lib/redbooth-ruby/helpers.rb +32 -0
- data/lib/redbooth-ruby/operations/base.rb +3 -2
- data/lib/redbooth-ruby/request/collection.rb +3 -2
- data/lib/redbooth-ruby/request/connection.rb +66 -30
- data/lib/redbooth-ruby/request/helpers.rb +2 -2
- data/lib/redbooth-ruby/request/info.rb +1 -1
- data/lib/redbooth-ruby/request/validator.rb +2 -2
- data/lib/redbooth-ruby/session.rb +34 -11
- data/lib/redbooth-ruby/task_list.rb +28 -0
- data/lib/redbooth-ruby/version.rb +2 -2
- data/lib/redbooth-ruby.rb +6 -3
- data/spec/cassettes/RedboothRuby_File/_download/downloads_a_file.yml +354 -0
- data/spec/cassettes/RedboothRuby_Organization/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_organization.yml +4 -4
- data/spec/cassettes/RedboothRuby_Project/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_project.yml +110 -110
- data/spec/cassettes/RedboothRuby_Session/_refresh_access_token_/.yml +55 -0
- data/spec/cassettes/RedboothRuby_Session/_refresh_access_token_/call_on_token_refresh_with_the_old_and_new_token.yml +55 -0
- data/spec/cassettes/RedboothRuby_Session/_refresh_access_token_/refreshes_the_access_token.yml +55 -0
- data/spec/redbooth-ruby/base_spec.rb +5 -5
- data/spec/redbooth-ruby/client_operations/metadata_spec.rb +4 -4
- data/spec/redbooth-ruby/client_operations/perform_spec.rb +135 -0
- data/spec/redbooth-ruby/client_operations/search_spec.rb +4 -4
- data/spec/redbooth-ruby/client_spec.rb +2 -43
- data/spec/redbooth-ruby/comment_spec.rb +17 -18
- data/spec/redbooth-ruby/conversation_spec.rb +16 -16
- data/spec/redbooth-ruby/file_spec.rb +29 -22
- data/spec/redbooth-ruby/me_spec.rb +2 -2
- data/spec/redbooth-ruby/membership_spec.rb +18 -18
- data/spec/redbooth-ruby/note_spec.rb +16 -16
- data/spec/redbooth-ruby/organization_spec.rb +16 -16
- data/spec/redbooth-ruby/person_spec.rb +18 -18
- data/spec/redbooth-ruby/project_spec.rb +18 -18
- data/spec/redbooth-ruby/request/base_spec.rb +5 -5
- data/spec/redbooth-ruby/request/collection_spec.rb +3 -3
- data/spec/redbooth-ruby/request/connection_spec.rb +8 -8
- data/spec/redbooth-ruby/request/info_spec.rb +13 -13
- data/spec/redbooth-ruby/request/response_spec.rb +4 -4
- data/spec/redbooth-ruby/request/validator_spec.rb +7 -7
- data/spec/redbooth-ruby/session_spec.rb +100 -0
- data/spec/redbooth-ruby/subtaks_spec.rb +16 -16
- data/spec/redbooth-ruby/task_spec.rb +22 -22
- data/spec/redbooth-ruby/user_spec.rb +4 -4
- data/spec/redbooth_spec.rb +13 -13
- data/spec/spec_helper.rb +2 -3
- data/temp/spec/files/test_download.txt +8 -0
- metadata +41 -24
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Membership, vcr: 'membership' do
|
4
4
|
include_context 'authentication'
|
@@ -14,7 +14,7 @@ describe RedboothRuby::Membership, vcr: 'membership' do
|
|
14
14
|
client.membership(:show, id: 1)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe '#initialize' do
|
18
18
|
subject { membership }
|
19
19
|
|
20
20
|
it { expect(subject.id).to eql 1 }
|
@@ -22,11 +22,11 @@ describe RedboothRuby::Membership, vcr: 'membership' do
|
|
22
22
|
it { expect(subject.role).to eql 'admin' }
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe '.show' do
|
26
26
|
subject { membership }
|
27
27
|
|
28
|
-
it
|
29
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint_name}/1", {}, { session: session }).and_call_original
|
28
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific membership' do
|
29
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{ endpoint_name }/1", {}, { session: session }).and_call_original
|
30
30
|
subject
|
31
31
|
end
|
32
32
|
|
@@ -35,11 +35,11 @@ describe RedboothRuby::Membership, vcr: 'membership' do
|
|
35
35
|
it { expect(subject.role).to eql 'admin' }
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe '.update' do
|
39
39
|
subject { client.membership(:update, id: 6, role: 'admin') }
|
40
40
|
|
41
|
-
it
|
42
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint_name}/6", { role: 'admin' }, { session: session }).and_call_original
|
41
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific membership' do
|
42
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{ endpoint_name }/6", { role: 'admin' }, { session: session }).and_call_original
|
43
43
|
subject
|
44
44
|
end
|
45
45
|
|
@@ -47,12 +47,12 @@ describe RedboothRuby::Membership, vcr: 'membership' do
|
|
47
47
|
it { expect(subject.id).to eql 6 }
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
50
|
+
describe '.create' do
|
51
51
|
subject { new_record }
|
52
52
|
let(:response) { double(:response, data: {} )}
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(RedboothRuby).to receive(:request).with(:post, nil,
|
54
|
+
it 'makes a new POST request using the correct API endpoint to create a specific membership' do
|
55
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint_name, create_params, { session: session }).and_return(response)
|
56
56
|
subject
|
57
57
|
end
|
58
58
|
|
@@ -63,23 +63,23 @@ describe RedboothRuby::Membership, vcr: 'membership' do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe
|
66
|
+
describe '.delete' do
|
67
67
|
subject { client.membership(:delete, id: new_record.id) }
|
68
68
|
|
69
|
-
it
|
70
|
-
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint_name}/#{new_record.id}", {}, { session: session }).and_call_original
|
69
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific membership' do
|
70
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{ endpoint_name }/#{ new_record.id }", {}, { session: session }).and_call_original
|
71
71
|
subject
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
75
|
+
describe '.index' do
|
76
76
|
subject { client.membership(:index) }
|
77
77
|
|
78
|
-
it
|
79
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
78
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific membership' do
|
79
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint_name, {}, { session: session }).and_call_original
|
80
80
|
subject
|
81
81
|
end
|
82
82
|
|
83
83
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
84
84
|
end
|
85
|
-
end
|
85
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Note, vcr: 'notes' do
|
4
4
|
include_context 'authentication'
|
@@ -14,7 +14,7 @@ describe RedboothRuby::Note, vcr: 'notes' do
|
|
14
14
|
client.note(:show, id: 1)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe '#initialize' do
|
18
18
|
subject { note }
|
19
19
|
|
20
20
|
it { expect(subject.id).to eql 1 }
|
@@ -24,11 +24,11 @@ describe RedboothRuby::Note, vcr: 'notes' do
|
|
24
24
|
it { expect(subject.is_private).to eql false }
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe '.show' do
|
28
28
|
subject { note }
|
29
29
|
|
30
|
-
it
|
31
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint}/1", {}, { session: session }).and_call_original
|
30
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific note' do
|
31
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{ endpoint }/1", {}, { session: session }).and_call_original
|
32
32
|
subject
|
33
33
|
end
|
34
34
|
|
@@ -37,11 +37,11 @@ describe RedboothRuby::Note, vcr: 'notes' do
|
|
37
37
|
it { expect(subject.project_id).to eql 2 }
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
40
|
+
describe '.update' do
|
41
41
|
subject { client.note(:update, id: 2, name: 'new test name') }
|
42
42
|
|
43
|
-
it
|
44
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint}/2", { name: 'new test name' }, { session: session }).and_call_original
|
43
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific note' do
|
44
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{ endpoint }/2", { name: 'new test name' }, { session: session }).and_call_original
|
45
45
|
subject
|
46
46
|
end
|
47
47
|
|
@@ -49,10 +49,10 @@ describe RedboothRuby::Note, vcr: 'notes' do
|
|
49
49
|
it { expect(subject.id).to eql 2 }
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
52
|
+
describe '.create' do
|
53
53
|
subject { new_record }
|
54
54
|
|
55
|
-
it
|
55
|
+
it 'makes a new POST request using the correct API endpoint to create a specific note' do
|
56
56
|
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params, { session: session }).and_call_original
|
57
57
|
subject
|
58
58
|
end
|
@@ -62,23 +62,23 @@ describe RedboothRuby::Note, vcr: 'notes' do
|
|
62
62
|
it { expect(subject.user_id).to eql 1 }
|
63
63
|
end
|
64
64
|
|
65
|
-
describe
|
65
|
+
describe '.delete' do
|
66
66
|
subject { client.note(:delete, id: new_record.id) }
|
67
67
|
|
68
|
-
it
|
69
|
-
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint}/#{new_record.id}", {}, { session: session }).and_call_original
|
68
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific note' do
|
69
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{ endpoint }/#{ new_record.id }", {}, { session: session }).and_call_original
|
70
70
|
subject
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
describe
|
74
|
+
describe '.index' do
|
75
75
|
subject { client.note(:index) }
|
76
76
|
|
77
|
-
it
|
77
|
+
it 'makes a new GET request using the correct API endpoint to receive notes collection' do
|
78
78
|
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, {}, { session: session }).and_call_original
|
79
79
|
subject
|
80
80
|
end
|
81
81
|
|
82
82
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
83
83
|
end
|
84
|
-
end
|
84
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Organization, vcr: 'organization' do
|
4
4
|
include_context 'authentication'
|
@@ -11,7 +11,7 @@ describe RedboothRuby::Organization, vcr: 'organization' do
|
|
11
11
|
client.organization(:show, id: 1)
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
14
|
+
describe '#initialize' do
|
15
15
|
subject { organization }
|
16
16
|
|
17
17
|
it { expect(subject.id).to eql 1 }
|
@@ -20,11 +20,11 @@ describe RedboothRuby::Organization, vcr: 'organization' do
|
|
20
20
|
it { expect(subject.domain).to eql nil }
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
23
|
+
describe '.show' do
|
24
24
|
subject { organization }
|
25
25
|
|
26
|
-
it
|
27
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
26
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific organization' do
|
27
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'organizations/1', {}, { session: session }).and_call_original
|
28
28
|
subject
|
29
29
|
end
|
30
30
|
|
@@ -34,11 +34,11 @@ describe RedboothRuby::Organization, vcr: 'organization' do
|
|
34
34
|
it { expect(subject.domain).to eql nil }
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
37
|
+
describe '.update' do
|
38
38
|
subject { client.organization(:update, id: 2, name: 'new test name') }
|
39
39
|
|
40
|
-
it
|
41
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil,
|
40
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific organization' do
|
41
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, 'organizations/2', { name: 'new test name' }, { session: session }).and_call_original
|
42
42
|
subject
|
43
43
|
end
|
44
44
|
|
@@ -46,10 +46,10 @@ describe RedboothRuby::Organization, vcr: 'organization' do
|
|
46
46
|
it { expect(subject.id).to eql 2 }
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
49
|
+
describe '.create' do
|
50
50
|
subject { new_organization }
|
51
51
|
|
52
|
-
it
|
52
|
+
it 'makes a new POST request using the correct API endpoint to create a specific organization' do
|
53
53
|
expect(RedboothRuby).to receive(:request).with(:post, nil, "organizations", create_organization_params, { session: session }).and_call_original
|
54
54
|
subject
|
55
55
|
end
|
@@ -57,24 +57,24 @@ describe RedboothRuby::Organization, vcr: 'organization' do
|
|
57
57
|
it { expect(subject.name).to eql 'new Organization' }
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
60
|
+
describe '.delete' do
|
61
61
|
subject { client.organization(:delete, id: new_organization.id) }
|
62
62
|
before { allow_any_instance_of(RedboothRuby::Client).to receive(:sleep) }
|
63
63
|
|
64
|
-
it
|
64
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific organization' do
|
65
65
|
expect(RedboothRuby).to receive(:request).with(:delete, nil, "organizations/#{new_organization.id}", {}, { session: session }).twice.and_call_original
|
66
66
|
subject
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe '.index' do
|
71
71
|
subject { client.organization(:index) }
|
72
72
|
|
73
|
-
it
|
74
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
73
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific organization' do
|
74
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'organizations', {}, { session: session }).and_call_original
|
75
75
|
subject
|
76
76
|
end
|
77
77
|
|
78
78
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
79
79
|
end
|
80
|
-
end
|
80
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Person, vcr: 'person' do
|
4
4
|
include_context 'authentication'
|
@@ -14,7 +14,7 @@ describe RedboothRuby::Person, vcr: 'person' do
|
|
14
14
|
client.person(:show, id: 1)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe '#initialize' do
|
18
18
|
subject { person }
|
19
19
|
|
20
20
|
it { expect(subject.id).to eql 1 }
|
@@ -22,11 +22,11 @@ describe RedboothRuby::Person, vcr: 'person' do
|
|
22
22
|
it { expect(subject.role).to eql 'admin' }
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe '.show' do
|
26
26
|
subject { person }
|
27
27
|
|
28
|
-
it
|
29
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint_name}/1", {}, { session: session }).and_call_original
|
28
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific person' do
|
29
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{ endpoint_name }/1", {}, { session: session }).and_call_original
|
30
30
|
subject
|
31
31
|
end
|
32
32
|
|
@@ -35,11 +35,11 @@ describe RedboothRuby::Person, vcr: 'person' do
|
|
35
35
|
it { expect(subject.role).to eql 'admin' }
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe '.update' do
|
39
39
|
subject { client.person(:update, id: 6, role: 'admin') }
|
40
40
|
|
41
|
-
it
|
42
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint_name}/6", { role: 'admin' }, { session: session }).and_call_original
|
41
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific person' do
|
42
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{ endpoint_name }/6", { role: 'admin' }, { session: session }).and_call_original
|
43
43
|
subject
|
44
44
|
end
|
45
45
|
|
@@ -47,12 +47,12 @@ describe RedboothRuby::Person, vcr: 'person' do
|
|
47
47
|
it { expect(subject.id).to eql 6 }
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
50
|
+
describe '.create' do
|
51
51
|
subject { new_person }
|
52
52
|
let(:response) { double(:response, data: {} )}
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(RedboothRuby).to receive(:request).with(:post, nil,
|
54
|
+
it 'makes a new POST request using the correct API endpoint to create a specific person' do
|
55
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint_name, create_params, { session: session }).and_return(response)
|
56
56
|
subject
|
57
57
|
end
|
58
58
|
|
@@ -63,23 +63,23 @@ describe RedboothRuby::Person, vcr: 'person' do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe
|
66
|
+
describe '.delete' do
|
67
67
|
subject { client.person(:delete, id: new_person.id) }
|
68
68
|
|
69
|
-
it
|
70
|
-
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint_name}/#{new_person.id}", {}, { session: session }).and_call_original
|
69
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific person' do
|
70
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{ endpoint_name }/#{ new_person.id }", {}, { session: session }).and_call_original
|
71
71
|
subject
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
75
|
+
describe '.index' do
|
76
76
|
subject { client.person(:index) }
|
77
77
|
|
78
|
-
it
|
79
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
78
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific person' do
|
79
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint_name, {}, { session: session }).and_call_original
|
80
80
|
subject
|
81
81
|
end
|
82
82
|
|
83
83
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
84
84
|
end
|
85
|
-
end
|
85
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Project, vcr: 'project' do
|
4
4
|
include_context 'authentication'
|
@@ -13,7 +13,7 @@ describe RedboothRuby::Project, vcr: 'project' do
|
|
13
13
|
client.project(:show, id: 1)
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe '#initialize' do
|
17
17
|
subject { project }
|
18
18
|
|
19
19
|
it { expect(subject.id).to eql 1 }
|
@@ -21,11 +21,11 @@ describe RedboothRuby::Project, vcr: 'project' do
|
|
21
21
|
it { expect(subject.permalink).to eql 'general' }
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe '.show' do
|
25
25
|
subject { project }
|
26
26
|
|
27
|
-
it
|
28
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint_name}/1", {}, { session: session }).and_call_original
|
27
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific project' do
|
28
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{ endpoint_name }/1", {}, { session: session }).and_call_original
|
29
29
|
subject
|
30
30
|
end
|
31
31
|
|
@@ -34,11 +34,11 @@ describe RedboothRuby::Project, vcr: 'project' do
|
|
34
34
|
it { expect(subject.permalink).to eql 'general' }
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
37
|
+
describe '.update' do
|
38
38
|
subject { client.project(:update, id: 2, name: 'new test name') }
|
39
39
|
|
40
|
-
it
|
41
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint_name}/2", { name: 'new test name' }, { session: session }).and_call_original
|
40
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific project' do
|
41
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{ endpoint_name }/2", { name: 'new test name' }, { session: session }).and_call_original
|
42
42
|
subject
|
43
43
|
end
|
44
44
|
|
@@ -46,35 +46,35 @@ describe RedboothRuby::Project, vcr: 'project' do
|
|
46
46
|
it { expect(subject.id).to eql 2 }
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
49
|
+
describe '.create' do
|
50
50
|
subject { new_project }
|
51
51
|
|
52
|
-
it
|
53
|
-
expect(RedboothRuby).to receive(:request).with(:post, nil,
|
52
|
+
it 'makes a new POST request using the correct API endpoint to create a specific project' do
|
53
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint_name, create_params, { session: session }).and_call_original
|
54
54
|
subject
|
55
55
|
end
|
56
56
|
|
57
57
|
it { expect(subject.name).to eql 'new Project' }
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
60
|
+
describe '.delete' do
|
61
61
|
subject { client.project(:delete, id: new_project.id) }
|
62
62
|
before { allow_any_instance_of(RedboothRuby::Client).to receive(:sleep) }
|
63
63
|
|
64
|
-
it
|
65
|
-
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint_name}/#{new_project.id}", {}, { session: session }).at_least(:twice).and_call_original
|
64
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific project' do
|
65
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{ endpoint_name }/#{ new_project.id }", {}, { session: session }).at_least(:twice).and_call_original
|
66
66
|
subject
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe '.index' do
|
71
71
|
subject { client.project(:index) }
|
72
72
|
|
73
|
-
it
|
74
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
73
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific project' do
|
74
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint_name, {}, { session: session }).and_call_original
|
75
75
|
subject
|
76
76
|
end
|
77
77
|
|
78
78
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
79
79
|
end
|
80
|
-
end
|
80
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Base do
|
4
4
|
let(:consumer_key) { '_your_consumen_key_' }
|
@@ -18,12 +18,12 @@ describe RedboothRuby::Request::Base do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe '#perform' do
|
22
22
|
it 'raises AuthenticationError if request is not valid' do
|
23
23
|
allow(request_base).to receive(:valid?).and_return(false)
|
24
24
|
expect{request_base.perform}.to raise_error{ RedboothRuby::AuthenticationError }
|
25
25
|
end
|
26
|
-
it
|
26
|
+
it 'performs an https request' do
|
27
27
|
allow_any_instance_of(RedboothRuby::Request::Base).to receive(:valid?).and_return(true)
|
28
28
|
|
29
29
|
expect(connection).to receive(:set_request_data)
|
@@ -34,7 +34,7 @@ describe RedboothRuby::Request::Base do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe
|
37
|
+
describe '#valid?' do
|
38
38
|
it 'is not valid if no info object given' do
|
39
39
|
expect(RedboothRuby::Request::Base.new(nil)).to_not be_valid
|
40
40
|
end
|
@@ -50,4 +50,4 @@ describe RedboothRuby::Request::Base do
|
|
50
50
|
expect(request_base).to be_valid
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Collection, vcr: 'collection' do
|
4
4
|
include_context 'authentication'
|
5
5
|
let(:collection) { client.task(:index, per_page: 2) }
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe '#initialize' do
|
8
8
|
subject { collection }
|
9
9
|
|
10
10
|
it { should be_a RedboothRuby::Request::Collection }
|
@@ -101,4 +101,4 @@ describe RedboothRuby::Request::Collection, vcr: 'collection' do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
end
|
104
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Connection do
|
4
4
|
let(:consumer_key) { '_your_consumen_key_' }
|
@@ -21,7 +21,7 @@ describe RedboothRuby::Request::Connection do
|
|
21
21
|
let(:client) { RedboothRuby::Client.new(session) }
|
22
22
|
let(:session) { RedboothRuby::Session.new(access_token) }
|
23
23
|
let(:redbooth_protocol) { RedboothRuby.configuration[:use_ssl] ? 'https' : 'http' }
|
24
|
-
let(:redbooth_url) { "#{redbooth_protocol}://#{RedboothRuby.configuration[:api_base]}/#{RedboothRuby.configuration[:api_base_path]}/#{RedboothRuby.configuration[:api_version]}" }
|
24
|
+
let(:redbooth_url) { "#{ redbooth_protocol }://#{ RedboothRuby.configuration[:api_base] }/#{ RedboothRuby.configuration[:api_base_path] }/#{ RedboothRuby.configuration[:api_version] }" }
|
25
25
|
|
26
26
|
before :each do
|
27
27
|
RedboothRuby.config do |configuration|
|
@@ -64,9 +64,9 @@ describe RedboothRuby::Request::Connection do
|
|
64
64
|
expect(connection.request_data).to eq(
|
65
65
|
[
|
66
66
|
:post,
|
67
|
-
"#{redbooth_url}/some/path",
|
68
|
-
{ body: { email:
|
69
|
-
event_types: [
|
67
|
+
"#{ redbooth_url }/some/path",
|
68
|
+
{ body: { email: 'abc_abc.com',
|
69
|
+
event_types: ['user.created', 'user.failed', 'team.created', 'documents.available'] }
|
70
70
|
}
|
71
71
|
]
|
72
72
|
)
|
@@ -75,8 +75,8 @@ describe RedboothRuby::Request::Connection do
|
|
75
75
|
|
76
76
|
def params
|
77
77
|
{
|
78
|
-
email:
|
79
|
-
event_types: [
|
78
|
+
email: 'abc_abc.com',
|
79
|
+
event_types: ['user.created', 'user.failed', 'team.created', 'documents.available']
|
80
80
|
}
|
81
81
|
end
|
82
|
-
end
|
82
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Info do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
info = RedboothRuby::Request::Info.new(:get, nil,
|
4
|
+
describe '#url' do
|
5
|
+
it 'constructs the url' do
|
6
|
+
info = RedboothRuby::Request::Info.new(:get, nil, 'random', { id: 1 })
|
7
7
|
|
8
8
|
expect(info.url).to match /random/
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
14
|
-
info = RedboothRuby::Request::Info.new(:get, nil,
|
15
|
-
path =
|
12
|
+
describe '#path_with_params' do
|
13
|
+
it 'does nothing when no params' do
|
14
|
+
info = RedboothRuby::Request::Info.new(:get, nil, 'random', nil)
|
15
|
+
path = '/path/to/someplace'
|
16
16
|
|
17
17
|
expect(info.path_with_params(path, {})).to eq path
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
info = RedboothRuby::Request::Info.new(:get, nil,
|
22
|
-
path =
|
20
|
+
it 'constructs the path with params' do
|
21
|
+
info = RedboothRuby::Request::Info.new(:get, nil, 'random', nil)
|
22
|
+
path = '/path/to/someplace'
|
23
23
|
|
24
|
-
expect(info.path_with_params(path, {random:
|
24
|
+
expect(info.path_with_params(path, { random: 'stuff' })).to eq "#{ path }?random=stuff"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Response do
|
4
4
|
let(:headers) { {} }
|
@@ -8,11 +8,11 @@ describe RedboothRuby::Request::Response do
|
|
8
8
|
status: status,
|
9
9
|
headers: headers) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe '#initialize' do
|
12
12
|
subject { response }
|
13
13
|
|
14
14
|
it { should be_a RedboothRuby::Request::Response }
|
15
|
-
it { expect(subject.data).to eq(
|
15
|
+
it { expect(subject.data).to eq('response' => 'ok') }
|
16
16
|
it { expect(subject.body).to eq(body) }
|
17
17
|
it { expect(subject.headers).to eq(headers) }
|
18
18
|
it { expect(subject.status).to eq(status) }
|
@@ -29,4 +29,4 @@ describe RedboothRuby::Request::Response do
|
|
29
29
|
it { expect(subject.data).to be_empty }
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Request::Validator do
|
4
|
-
let(:info) { RedboothRuby::Request::Info.new(:get, nil,
|
4
|
+
let(:info) { RedboothRuby::Request::Info.new(:get, nil, 'random', OpenStruct.new(id: 1)) }
|
5
5
|
let(:validator) { RedboothRuby::Request::Validator.new info }
|
6
6
|
let(:headers) { {} }
|
7
7
|
let(:response) { OpenStruct.new(body: '{"response":"ok"}', status: 200, headers: headers) }
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#validated_response_for' do
|
10
10
|
subject { validator.validated_response_for(response) }
|
11
11
|
|
12
12
|
it { should be_a RedboothRuby::Request::Response }
|
13
|
-
it { expect(subject.data).to eq(
|
13
|
+
it { expect(subject.data).to eq('response' => 'ok') }
|
14
14
|
|
15
15
|
context 'where 401 status code returned' do
|
16
16
|
let(:response) { OpenStruct.new(body: '{"error":{"message":"Unauthorized"}}', status: 401, headers: headers) }
|
@@ -20,13 +20,13 @@ describe RedboothRuby::Request::Validator do
|
|
20
20
|
context 'where token was expired' do
|
21
21
|
before { headers['WWW-Authenticate'] = %{Bearer realm="Doorkeeper", error="invalid_token", error_description="The access token was expired"} }
|
22
22
|
|
23
|
-
it { expect{subject}.to raise_error(RedboothRuby::
|
23
|
+
it { expect{subject}.to raise_error(RedboothRuby::OauthTokenExpired) }
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'where token was revoked' do
|
27
27
|
before { headers['WWW-Authenticate'] = %{Bearer realm="Doorkeeper", error="invalid_token", error_description="The access token was revoked"} }
|
28
28
|
|
29
|
-
it { expect{subject}.to raise_error(RedboothRuby::
|
29
|
+
it { expect{subject}.to raise_error(RedboothRuby::OauthTokenRevoked) }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -42,4 +42,4 @@ describe RedboothRuby::Request::Validator do
|
|
42
42
|
it { expect{subject}.to raise_error(RedboothRuby::NotFound) }
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|