redbooth-ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/spec/cassettes/RedboothRuby_Conversation/_create/.yml +47 -0
- data/spec/cassettes/RedboothRuby_Conversation/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_conversation.yml +47 -0
- data/spec/cassettes/RedboothRuby_Conversation/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_conversation.yml +84 -0
- data/spec/cassettes/RedboothRuby_Conversation/_index/.yml +99 -0
- data/spec/cassettes/RedboothRuby_Conversation/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_conversations_collection.yml +99 -0
- data/spec/cassettes/RedboothRuby_Conversation/_initialize/.yml +45 -0
- data/spec/cassettes/RedboothRuby_Conversation/_show/.yml +45 -0
- data/spec/cassettes/RedboothRuby_Conversation/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_conversation.yml +45 -0
- data/spec/cassettes/RedboothRuby_Conversation/_update/.yml +47 -0
- data/spec/cassettes/RedboothRuby_Conversation/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_conversation.yml +47 -0
- data/spec/cassettes/{Redbooth_Me → RedboothRuby_Me}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Me → RedboothRuby_Me}/_show/.yml +0 -0
- data/spec/cassettes/{Redbooth_Me → RedboothRuby_Me}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_user.yml +0 -0
- data/spec/cassettes/{Redbooth_Me → RedboothRuby_Me}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_Me → RedboothRuby_Me}/_update/integration/.yml +0 -0
- data/spec/cassettes/RedboothRuby_Membership/_create/integration/.yml +83 -0
- data/spec/cassettes/RedboothRuby_Membership/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_membership.yml +83 -0
- data/spec/cassettes/RedboothRuby_Membership/_index/.yml +58 -0
- data/spec/cassettes/RedboothRuby_Membership/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_membership.yml +58 -0
- data/spec/cassettes/RedboothRuby_Membership/_initialize/.yml +44 -0
- data/spec/cassettes/RedboothRuby_Membership/_show/.yml +44 -0
- data/spec/cassettes/RedboothRuby_Membership/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_membership.yml +44 -0
- data/spec/cassettes/RedboothRuby_Membership/_update/.yml +46 -0
- data/spec/cassettes/RedboothRuby_Membership/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_membership.yml +46 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_create/.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_organization.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_organization.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_index/.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_show/.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_Organization → RedboothRuby_Organization}/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_create/integration/.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_person.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_person.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_index/.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_show/.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_Person → RedboothRuby_Person}/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_create/.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_project.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_project.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_index/.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_show/.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_Project → RedboothRuby_Project}/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_all/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_count/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_current_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_current_page/where_endpoint_is_not_paginated/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_next_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_next_page/where_endpoint_is_not_paginated/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_next_page/where_is_the_last_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_per_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_per_page/where_endpoint_is_not_paginated/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_prev_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_prev_page/where_endpoint_is_not_paginated/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_prev_page/where_is_the_first_page/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_total_pages/.yml +0 -0
- data/spec/cassettes/{Redbooth_Request_Collection → RedboothRuby_Request_Collection}/_total_pages/where_endpoint_is_not_paginated/.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_create/.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_index/.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_show/returns_a_task_with_the_correct_assigned_id.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_show/returns_a_task_with_the_correct_id.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_show/returns_a_task_with_the_correct_name.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_show/returns_a_task_with_the_correct_project_id.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_Task → RedboothRuby_Task}/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/name/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/project_id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_create/task_list_id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_index/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_index/class/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/assigned_id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/description/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/due_on/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/initializes_all_attributes_correctly.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/name/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_initialize/project_id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_user.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_task_with_the_correct_assigned_id.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_task_with_the_correct_id.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_task_with_the_correct_name.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_task_with_the_correct_project_id.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_user_with_the_correct_email.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_user_with_the_correct_first_name.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_user_with_the_correct_id.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_show/returns_a_user_with_the_correct_last_name.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_update/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_update/id/.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +0 -0
- data/spec/cassettes/{Redbooth_User → RedboothRuby_User}/_update/name/.yml +0 -0
- data/spec/{redbooth → redbooth-ruby}/base_spec.rb +2 -2
- data/spec/{redbooth → redbooth-ruby}/client_spec.rb +11 -11
- data/spec/redbooth-ruby/conversation_spec.rb +83 -0
- data/spec/{redbooth → redbooth-ruby}/me_spec.rb +4 -4
- data/spec/redbooth-ruby/membership_spec.rb +85 -0
- data/spec/{redbooth → redbooth-ruby}/organization_spec.rb +8 -8
- data/spec/{redbooth → redbooth-ruby}/person_spec.rb +7 -7
- data/spec/{redbooth → redbooth-ruby}/project_spec.rb +8 -8
- data/spec/{redbooth → redbooth-ruby}/request/base_spec.rb +9 -9
- data/spec/{redbooth → redbooth-ruby}/request/collection_spec.rb +7 -7
- data/spec/{redbooth → redbooth-ruby}/request/connection_spec.rb +10 -10
- data/spec/{redbooth → redbooth-ruby}/request/info_spec.rb +4 -4
- data/spec/{redbooth → redbooth-ruby}/request/response_spec.rb +3 -3
- data/spec/{redbooth → redbooth-ruby}/request/validator_spec.rb +9 -9
- data/spec/{redbooth → redbooth-ruby}/task_spec.rb +12 -12
- data/spec/{redbooth → redbooth-ruby}/user_spec.rb +4 -4
- data/spec/redbooth_spec.rb +12 -12
- data/spec/shared/authentication_context.rb +3 -3
- data/spec/spec_helper.rb +5 -1
- metadata +264 -222
@@ -0,0 +1,83 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RedboothRuby::Conversation, vcr: 'conversations' do
|
4
|
+
include_context 'authentication'
|
5
|
+
|
6
|
+
let(:create_params) do
|
7
|
+
{ project_id: 2,
|
8
|
+
name: 'new created conversation' }
|
9
|
+
end
|
10
|
+
let(:new_record) { client.conversation(:create, create_params) }
|
11
|
+
let(:endpoint) { 'conversations' }
|
12
|
+
let(:conversation) do
|
13
|
+
client.conversation(:show, id: 1)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#initialize" do
|
17
|
+
subject { conversation }
|
18
|
+
|
19
|
+
it { expect(subject.id).to eql 1 }
|
20
|
+
it { expect(subject.name).to eql 'Project Welcome' }
|
21
|
+
it { expect(subject.project_id).to eql 2 }
|
22
|
+
it { expect(subject.user_id).to eql 1 }
|
23
|
+
it { expect(subject.is_private).to eql false }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".show" do
|
27
|
+
subject { conversation }
|
28
|
+
|
29
|
+
it "makes a new GET request using the correct API endpoint to receive a specific conversation" do
|
30
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint}/1", {}, { session: session }).and_call_original
|
31
|
+
subject
|
32
|
+
end
|
33
|
+
|
34
|
+
it { expect(subject.id).to eql 1 }
|
35
|
+
it { expect(subject.name).to eql 'Project Welcome' }
|
36
|
+
it { expect(subject.project_id).to eql 2 }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".update" do
|
40
|
+
subject { client.conversation(:update, id: 2, name: 'new test name') }
|
41
|
+
|
42
|
+
it "makes a new PUT request using the correct API endpoint to receive a specific conversation" do
|
43
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint}/2", { name: 'new test name' }, { session: session }).and_call_original
|
44
|
+
subject
|
45
|
+
end
|
46
|
+
|
47
|
+
it { expect(subject.name).to eql 'new test name' }
|
48
|
+
it { expect(subject.id).to eql 2 }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".create" do
|
52
|
+
subject { new_record }
|
53
|
+
|
54
|
+
it "makes a new POST request using the correct API endpoint to create a specific conversation" do
|
55
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params, { session: session }).and_call_original
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
|
59
|
+
it { expect(subject.name).to eql 'new created conversation' }
|
60
|
+
it { expect(subject.project_id).to eql 2 }
|
61
|
+
it { expect(subject.user_id).to eql 1 }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".delete" do
|
65
|
+
subject { client.conversation(:delete, id: new_record.id) }
|
66
|
+
|
67
|
+
it "makes a new DELETE request using the correct API endpoint to delete a specific conversation" do
|
68
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint}/#{new_record.id}", {}, { session: session }).and_call_original
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".index" do
|
74
|
+
subject { client.conversation(:index) }
|
75
|
+
|
76
|
+
it "makes a new GET request using the correct API endpoint to receive conversations collection" do
|
77
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, {}, { session: session }).and_call_original
|
78
|
+
subject
|
79
|
+
end
|
80
|
+
|
81
|
+
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
82
|
+
end
|
83
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RedboothRuby::Me, vcr: 'me' do
|
4
4
|
include_context 'authentication'
|
5
5
|
let(:me) { client.me(:show) }
|
6
6
|
let(:response) { double(:response, data: {})}
|
@@ -18,7 +18,7 @@ describe Redbooth::Me, vcr: 'me' do
|
|
18
18
|
subject { me }
|
19
19
|
|
20
20
|
it 'makes a new GET request using the correct API endpoint to receive a specific user' do
|
21
|
-
expect(
|
21
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'me', {}, { session: session }).and_call_original
|
22
22
|
subject
|
23
23
|
end
|
24
24
|
|
@@ -33,7 +33,7 @@ describe Redbooth::Me, vcr: 'me' do
|
|
33
33
|
subject { client.me(:update, update_attributes) }
|
34
34
|
|
35
35
|
it 'makes a new PUT request using the correct API endpoint' do
|
36
|
-
expect(
|
36
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, 'me', update_attributes, { session: session }).and_return(response)
|
37
37
|
subject
|
38
38
|
end
|
39
39
|
|
@@ -48,7 +48,7 @@ describe Redbooth::Me, vcr: 'me' do
|
|
48
48
|
subject { client.me(:delete) }
|
49
49
|
|
50
50
|
it 'makes a new DELETE request using the correct API endpoint' do
|
51
|
-
expect(
|
51
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, 'me', {}, { session: session })
|
52
52
|
|
53
53
|
subject
|
54
54
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RedboothRuby::Membership, vcr: 'membership' do
|
4
|
+
include_context 'authentication'
|
5
|
+
|
6
|
+
let(:create_params) do
|
7
|
+
{ organization_id: 1,
|
8
|
+
user_id: 3,
|
9
|
+
role: 'participant' }
|
10
|
+
end
|
11
|
+
let(:endpoint_name) { 'memberships' }
|
12
|
+
let(:new_record) { client.membership(:create, create_params.merge(session: session)) }
|
13
|
+
let(:membership) do
|
14
|
+
client.membership(:show, id: 1)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#initialize" do
|
18
|
+
subject { membership }
|
19
|
+
|
20
|
+
it { expect(subject.id).to eql 1 }
|
21
|
+
it { expect(subject.user_id).to eql 1 }
|
22
|
+
it { expect(subject.role).to eql 'admin' }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".show" do
|
26
|
+
subject { membership }
|
27
|
+
|
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
|
+
subject
|
31
|
+
end
|
32
|
+
|
33
|
+
it { expect(subject.id).to eql 1 }
|
34
|
+
it { expect(subject.user_id).to eql 1 }
|
35
|
+
it { expect(subject.role).to eql 'admin' }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".update" do
|
39
|
+
subject { client.membership(:update, id: 6, role: 'admin') }
|
40
|
+
|
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
|
+
subject
|
44
|
+
end
|
45
|
+
|
46
|
+
it { expect(subject.role).to eql 'admin' }
|
47
|
+
it { expect(subject.id).to eql 6 }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".create" do
|
51
|
+
subject { new_record }
|
52
|
+
let(:response) { double(:response, data: {} )}
|
53
|
+
|
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
|
+
subject
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'integration' do
|
60
|
+
after { client.membership(:delete, id: subject.id) }
|
61
|
+
|
62
|
+
it { expect(subject.user_id).to eql 3 }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe ".delete" do
|
67
|
+
subject { client.membership(:delete, id: new_record.id) }
|
68
|
+
|
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
|
+
subject
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".index" do
|
76
|
+
subject { client.membership(:index) }
|
77
|
+
|
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
|
+
subject
|
81
|
+
end
|
82
|
+
|
83
|
+
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
84
|
+
end
|
85
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RedboothRuby::Organization, vcr: 'organization' do
|
4
4
|
include_context 'authentication'
|
5
5
|
|
6
6
|
let(:create_organization_params) do
|
@@ -24,7 +24,7 @@ describe Redbooth::Organization, vcr: 'organization' do
|
|
24
24
|
subject { organization }
|
25
25
|
|
26
26
|
it "makes a new GET request using the correct API endpoint to receive a specific organization" do
|
27
|
-
expect(
|
27
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "organizations/1", {}, { session: session }).and_call_original
|
28
28
|
subject
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ describe Redbooth::Organization, vcr: 'organization' do
|
|
38
38
|
subject { client.organization(:update, id: 2, name: 'new test name') }
|
39
39
|
|
40
40
|
it "makes a new PUT request using the correct API endpoint to receive a specific organization" do
|
41
|
-
expect(
|
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
|
|
@@ -50,7 +50,7 @@ describe Redbooth::Organization, vcr: 'organization' do
|
|
50
50
|
subject { new_organization }
|
51
51
|
|
52
52
|
it "makes a new POST request using the correct API endpoint to create a specific organization" do
|
53
|
-
expect(
|
53
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, "organizations", create_organization_params, { session: session }).and_call_original
|
54
54
|
subject
|
55
55
|
end
|
56
56
|
|
@@ -59,10 +59,10 @@ describe Redbooth::Organization, vcr: 'organization' do
|
|
59
59
|
|
60
60
|
describe ".delete" do
|
61
61
|
subject { client.organization(:delete, id: new_organization.id) }
|
62
|
-
before { allow_any_instance_of(
|
62
|
+
before { allow_any_instance_of(RedboothRuby::Client).to receive(:sleep) }
|
63
63
|
|
64
64
|
it "makes a new DELETE request using the correct API endpoint to delete a specific organization" do
|
65
|
-
expect(
|
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
|
@@ -71,10 +71,10 @@ describe Redbooth::Organization, vcr: 'organization' do
|
|
71
71
|
subject { client.organization(:index) }
|
72
72
|
|
73
73
|
it "makes a new PUT request using the correct API endpoint to receive a specific organization" do
|
74
|
-
expect(
|
74
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "organizations", {}, { session: session }).and_call_original
|
75
75
|
subject
|
76
76
|
end
|
77
77
|
|
78
|
-
it { expect(subject.class).to eql
|
78
|
+
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
79
79
|
end
|
80
80
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RedboothRuby::Person, vcr: 'person' do
|
4
4
|
include_context 'authentication'
|
5
5
|
|
6
6
|
let(:create_params) do
|
@@ -26,7 +26,7 @@ describe Redbooth::Person, vcr: 'person' do
|
|
26
26
|
subject { person }
|
27
27
|
|
28
28
|
it "makes a new GET request using the correct API endpoint to receive a specific person" do
|
29
|
-
expect(
|
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
|
|
@@ -39,7 +39,7 @@ describe Redbooth::Person, vcr: 'person' do
|
|
39
39
|
subject { client.person(:update, id: 6, role: 'admin') }
|
40
40
|
|
41
41
|
it "makes a new PUT request using the correct API endpoint to receive a specific person" do
|
42
|
-
expect(
|
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
|
|
@@ -52,7 +52,7 @@ describe Redbooth::Person, vcr: 'person' do
|
|
52
52
|
let(:response) { double(:response, data: {} )}
|
53
53
|
|
54
54
|
it "makes a new POST request using the correct API endpoint to create a specific person" do
|
55
|
-
expect(
|
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
|
|
@@ -67,7 +67,7 @@ describe Redbooth::Person, vcr: 'person' do
|
|
67
67
|
subject { client.person(:delete, id: new_person.id) }
|
68
68
|
|
69
69
|
it "makes a new DELETE request using the correct API endpoint to delete a specific person" do
|
70
|
-
expect(
|
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
|
@@ -76,10 +76,10 @@ describe Redbooth::Person, vcr: 'person' do
|
|
76
76
|
subject { client.person(:index) }
|
77
77
|
|
78
78
|
it "makes a new PUT request using the correct API endpoint to receive a specific person" do
|
79
|
-
expect(
|
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
|
-
it { expect(subject.class).to eql
|
83
|
+
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
84
84
|
end
|
85
85
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RedboothRuby::Project, vcr: 'project' do
|
4
4
|
include_context 'authentication'
|
5
5
|
|
6
6
|
let(:create_params) do
|
@@ -25,7 +25,7 @@ describe Redbooth::Project, vcr: 'project' do
|
|
25
25
|
subject { project }
|
26
26
|
|
27
27
|
it "makes a new GET request using the correct API endpoint to receive a specific project" do
|
28
|
-
expect(
|
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
|
|
@@ -38,7 +38,7 @@ describe Redbooth::Project, vcr: 'project' do
|
|
38
38
|
subject { client.project(:update, id: 2, name: 'new test name') }
|
39
39
|
|
40
40
|
it "makes a new PUT request using the correct API endpoint to receive a specific project" do
|
41
|
-
expect(
|
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
|
|
@@ -50,7 +50,7 @@ describe Redbooth::Project, vcr: 'project' do
|
|
50
50
|
subject { new_project }
|
51
51
|
|
52
52
|
it "makes a new POST request using the correct API endpoint to create a specific project" do
|
53
|
-
expect(
|
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
|
|
@@ -59,10 +59,10 @@ describe Redbooth::Project, vcr: 'project' do
|
|
59
59
|
|
60
60
|
describe ".delete" do
|
61
61
|
subject { client.project(:delete, id: new_project.id) }
|
62
|
-
before { allow_any_instance_of(
|
62
|
+
before { allow_any_instance_of(RedboothRuby::Client).to receive(:sleep) }
|
63
63
|
|
64
64
|
it "makes a new DELETE request using the correct API endpoint to delete a specific project" do
|
65
|
-
expect(
|
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
|
@@ -71,10 +71,10 @@ describe Redbooth::Project, vcr: 'project' do
|
|
71
71
|
subject { client.project(:index) }
|
72
72
|
|
73
73
|
it "makes a new PUT request using the correct API endpoint to receive a specific project" do
|
74
|
-
expect(
|
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
|
-
it { expect(subject.class).to eql
|
78
|
+
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
79
79
|
end
|
80
80
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RedboothRuby::Request::Base do
|
4
4
|
let(:consumer_key) { '_your_consumen_key_' }
|
5
5
|
let(:consumer_secret) { '_your_consumen_secret_' }
|
6
6
|
let(:info) { double(:info, session: session ) }
|
7
7
|
let(:session) { double(:session, valid?: true ) }
|
8
|
-
let(:request_base) {
|
8
|
+
let(:request_base) { RedboothRuby::Request::Base.new(info) }
|
9
9
|
let(:connection) { double(:connection) }
|
10
10
|
let(:validator) { double(:validator) }
|
11
11
|
|
12
12
|
before :each do
|
13
|
-
allow(
|
14
|
-
allow(
|
15
|
-
|
13
|
+
allow(RedboothRuby::Request::Connection).to receive(:new).and_return(connection)
|
14
|
+
allow(RedboothRuby::Request::Validator).to receive(:new).and_return(validator)
|
15
|
+
RedboothRuby.config do |configuration|
|
16
16
|
configuration[:consumer_key] = consumer_key
|
17
17
|
configuration[:consumer_secret] = consumer_secret
|
18
18
|
end
|
@@ -21,22 +21,22 @@ describe Redbooth::Request::Base do
|
|
21
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
|
-
expect{request_base.perform}.to raise_error{
|
24
|
+
expect{request_base.perform}.to raise_error{ RedboothRuby::AuthenticationError }
|
25
25
|
end
|
26
26
|
it "performs an https request" do
|
27
|
-
allow_any_instance_of(
|
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)
|
30
30
|
expect(connection).to receive(:request)
|
31
31
|
expect(validator).to receive(:validated_response_for)
|
32
32
|
|
33
|
-
|
33
|
+
RedboothRuby::Request::Base.new(nil).perform
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#valid?" do
|
38
38
|
it 'is not valid if no info object given' do
|
39
|
-
expect(
|
39
|
+
expect(RedboothRuby::Request::Base.new(nil)).to_not be_valid
|
40
40
|
end
|
41
41
|
it 'is not valid if there is no session in info object' do
|
42
42
|
allow(info).to receive(:session).and_return(nil)
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
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
7
|
describe "#initialize" do
|
8
8
|
subject { collection }
|
9
9
|
|
10
|
-
it { should be_a
|
11
|
-
it { expect(subject.response).to be_a(
|
10
|
+
it { should be_a RedboothRuby::Request::Collection }
|
11
|
+
it { expect(subject.response).to be_a(RedboothRuby::Request::Response) }
|
12
12
|
it { expect(subject.params).to be_a(Hash) }
|
13
13
|
it { expect(subject.method).to eql(:index) }
|
14
14
|
it { expect(subject.session).to eql(client.session) }
|
15
|
-
it { expect(subject.resource).to eql(
|
15
|
+
it { expect(subject.resource).to eql(RedboothRuby::Task) }
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#all' do
|
19
19
|
subject { collection.all }
|
20
20
|
|
21
21
|
it { should be_a Array }
|
22
|
-
it { expect(subject.first).to be_a(
|
22
|
+
it { expect(subject.first).to be_a(RedboothRuby::Task) }
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#total_pages' do
|
@@ -67,7 +67,7 @@ describe Redbooth::Request::Collection, vcr: 'collection' do
|
|
67
67
|
describe '#next_page' do
|
68
68
|
subject { collection.next_page }
|
69
69
|
|
70
|
-
it { should be_a
|
70
|
+
it { should be_a RedboothRuby::Request::Collection }
|
71
71
|
|
72
72
|
context 'where endpoint is not paginated' do
|
73
73
|
before { collection.response.headers.delete('PaginationCurrentPage') }
|
@@ -86,7 +86,7 @@ describe Redbooth::Request::Collection, vcr: 'collection' do
|
|
86
86
|
before { collection.response.headers['PaginationCurrentPage'] = 4 }
|
87
87
|
subject { collection.prev_page }
|
88
88
|
|
89
|
-
it { should be_a
|
89
|
+
it { should be_a RedboothRuby::Request::Collection }
|
90
90
|
|
91
91
|
context 'where endpoint is not paginated' do
|
92
92
|
before { collection.response.headers.delete('PaginationCurrentPage') }
|