redbooth-ruby 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/spec/cassettes/Redbooth_Me/_initialize/.yml +48 -0
  3. data/spec/cassettes/Redbooth_Me/_show/.yml +48 -0
  4. data/spec/cassettes/Redbooth_Me/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_user.yml +48 -0
  5. data/spec/cassettes/Redbooth_Me/_update/.yml +97 -0
  6. data/spec/cassettes/Redbooth_Me/_update/integration/.yml +97 -0
  7. data/spec/cassettes/Redbooth_Organization/_create/.yml +47 -0
  8. data/spec/cassettes/Redbooth_Organization/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_organization.yml +47 -0
  9. data/spec/cassettes/Redbooth_Organization/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_organization.yml +123 -0
  10. data/spec/cassettes/Redbooth_Organization/_index/.yml +58 -0
  11. data/spec/cassettes/Redbooth_Organization/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +58 -0
  12. data/spec/cassettes/Redbooth_Organization/_initialize/.yml +64 -0
  13. data/spec/cassettes/Redbooth_Organization/_show/.yml +64 -0
  14. data/spec/cassettes/Redbooth_Organization/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +64 -0
  15. data/spec/cassettes/Redbooth_Organization/_update/.yml +48 -0
  16. data/spec/cassettes/Redbooth_Organization/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_organization.yml +48 -0
  17. data/spec/cassettes/Redbooth_Person/_create/integration/.yml +83 -0
  18. data/spec/cassettes/Redbooth_Person/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_person.yml +83 -0
  19. data/spec/cassettes/Redbooth_Person/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_person.yml +83 -0
  20. data/spec/cassettes/Redbooth_Person/_index/.yml +127 -0
  21. data/spec/cassettes/Redbooth_Person/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +54 -0
  22. data/spec/cassettes/Redbooth_Person/_initialize/.yml +117 -0
  23. data/spec/cassettes/Redbooth_Person/_show/.yml +117 -0
  24. data/spec/cassettes/Redbooth_Person/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +44 -0
  25. data/spec/cassettes/Redbooth_Person/_update/.yml +163 -0
  26. data/spec/cassettes/Redbooth_Person/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_person.yml +294 -0
  27. data/spec/cassettes/Redbooth_Project/_create/.yml +47 -0
  28. data/spec/cassettes/Redbooth_Project/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_project.yml +47 -0
  29. data/spec/cassettes/Redbooth_Project/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_project.yml +2296 -0
  30. data/spec/cassettes/Redbooth_Project/_index/.yml +62 -0
  31. data/spec/cassettes/Redbooth_Project/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +62 -0
  32. data/spec/cassettes/Redbooth_Project/_initialize/.yml +44 -0
  33. data/spec/cassettes/Redbooth_Project/_show/.yml +44 -0
  34. data/spec/cassettes/Redbooth_Project/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +44 -0
  35. data/spec/cassettes/Redbooth_Project/_update/.yml +47 -0
  36. data/spec/cassettes/Redbooth_Project/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_project.yml +47 -0
  37. data/spec/cassettes/Redbooth_Request_Collection/_all/.yml +59 -0
  38. data/spec/cassettes/Redbooth_Request_Collection/_count/.yml +59 -0
  39. data/spec/cassettes/Redbooth_Request_Collection/_current_page/.yml +59 -0
  40. data/spec/cassettes/Redbooth_Request_Collection/_current_page/where_endpoint_is_not_paginated/.yml +59 -0
  41. data/spec/cassettes/Redbooth_Request_Collection/_initialize/.yml +59 -0
  42. data/spec/cassettes/Redbooth_Request_Collection/_next_page/.yml +106 -0
  43. data/spec/cassettes/Redbooth_Request_Collection/_next_page/where_endpoint_is_not_paginated/.yml +59 -0
  44. data/spec/cassettes/Redbooth_Request_Collection/_next_page/where_is_the_last_page/.yml +59 -0
  45. data/spec/cassettes/Redbooth_Request_Collection/_per_page/.yml +59 -0
  46. data/spec/cassettes/Redbooth_Request_Collection/_per_page/where_endpoint_is_not_paginated/.yml +59 -0
  47. data/spec/cassettes/Redbooth_Request_Collection/_prev_page/.yml +115 -0
  48. data/spec/cassettes/Redbooth_Request_Collection/_prev_page/where_endpoint_is_not_paginated/.yml +59 -0
  49. data/spec/cassettes/Redbooth_Request_Collection/_prev_page/where_is_the_first_page/.yml +159 -0
  50. data/spec/cassettes/Redbooth_Request_Collection/_total_pages/.yml +59 -0
  51. data/spec/cassettes/Redbooth_Request_Collection/_total_pages/where_endpoint_is_not_paginated/.yml +59 -0
  52. data/spec/cassettes/Redbooth_Task/_create/.yml +47 -0
  53. data/spec/cassettes/Redbooth_Task/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_task.yml +47 -0
  54. data/spec/cassettes/Redbooth_Task/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_task.yml +84 -0
  55. data/spec/cassettes/Redbooth_Task/_index/.yml +1037 -0
  56. data/spec/cassettes/Redbooth_Task/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +437 -0
  57. data/spec/cassettes/Redbooth_Task/_initialize/.yml +47 -0
  58. data/spec/cassettes/Redbooth_Task/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +47 -0
  59. data/spec/cassettes/Redbooth_Task/_show/returns_a_task_with_the_correct_assigned_id.yml +47 -0
  60. data/spec/cassettes/Redbooth_Task/_show/returns_a_task_with_the_correct_id.yml +47 -0
  61. data/spec/cassettes/Redbooth_Task/_show/returns_a_task_with_the_correct_name.yml +47 -0
  62. data/spec/cassettes/Redbooth_Task/_show/returns_a_task_with_the_correct_project_id.yml +47 -0
  63. data/spec/cassettes/Redbooth_Task/_update/.yml +47 -0
  64. data/spec/cassettes/Redbooth_Task/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +47 -0
  65. data/spec/cassettes/Redbooth_User/_create/.yml +84 -0
  66. data/spec/cassettes/Redbooth_User/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_task.yml +47 -0
  67. data/spec/cassettes/Redbooth_User/_create/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +47 -0
  68. data/spec/cassettes/Redbooth_User/_create/name/.yml +47 -0
  69. data/spec/cassettes/Redbooth_User/_create/project_id/.yml +47 -0
  70. data/spec/cassettes/Redbooth_User/_create/task_list_id/.yml +47 -0
  71. data/spec/cassettes/Redbooth_User/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_task.yml +84 -0
  72. data/spec/cassettes/Redbooth_User/_index/.yml +413 -0
  73. data/spec/cassettes/Redbooth_User/_index/class/.yml +400 -0
  74. data/spec/cassettes/Redbooth_User/_index/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +400 -0
  75. data/spec/cassettes/Redbooth_User/_initialize/.yml +88 -0
  76. data/spec/cassettes/Redbooth_User/_initialize/assigned_id/.yml +47 -0
  77. data/spec/cassettes/Redbooth_User/_initialize/description/.yml +47 -0
  78. data/spec/cassettes/Redbooth_User/_initialize/due_on/.yml +47 -0
  79. data/spec/cassettes/Redbooth_User/_initialize/id/.yml +47 -0
  80. data/spec/cassettes/Redbooth_User/_initialize/initializes_all_attributes_correctly.yml +44 -0
  81. data/spec/cassettes/Redbooth_User/_initialize/name/.yml +47 -0
  82. data/spec/cassettes/Redbooth_User/_initialize/project_id/.yml +47 -0
  83. data/spec/cassettes/Redbooth_User/_show/.yml +44 -0
  84. data/spec/cassettes/Redbooth_User/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +47 -0
  85. data/spec/cassettes/Redbooth_User/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_user.yml +88 -0
  86. data/spec/cassettes/Redbooth_User/_show/returns_a_task_with_the_correct_assigned_id.yml +47 -0
  87. data/spec/cassettes/Redbooth_User/_show/returns_a_task_with_the_correct_id.yml +47 -0
  88. data/spec/cassettes/Redbooth_User/_show/returns_a_task_with_the_correct_name.yml +47 -0
  89. data/spec/cassettes/Redbooth_User/_show/returns_a_task_with_the_correct_project_id.yml +47 -0
  90. data/spec/cassettes/Redbooth_User/_show/returns_a_user_with_the_correct_email.yml +393 -0
  91. data/spec/cassettes/Redbooth_User/_show/returns_a_user_with_the_correct_first_name.yml +393 -0
  92. data/spec/cassettes/Redbooth_User/_show/returns_a_user_with_the_correct_id.yml +393 -0
  93. data/spec/cassettes/Redbooth_User/_show/returns_a_user_with_the_correct_last_name.yml +393 -0
  94. data/spec/cassettes/Redbooth_User/_update/.yml +47 -0
  95. data/spec/cassettes/Redbooth_User/_update/id/.yml +47 -0
  96. data/spec/cassettes/Redbooth_User/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +47 -0
  97. data/spec/cassettes/Redbooth_User/_update/name/.yml +47 -0
  98. data/spec/fixtures/hola.txt +1 -0
  99. data/spec/redbooth/base_spec.rb +12 -0
  100. data/spec/redbooth/client_spec.rb +69 -0
  101. data/spec/redbooth/me_spec.rb +56 -0
  102. data/spec/redbooth/organization_spec.rb +80 -0
  103. data/spec/redbooth/person_spec.rb +85 -0
  104. data/spec/redbooth/project_spec.rb +80 -0
  105. data/spec/redbooth/request/base_spec.rb +53 -0
  106. data/spec/redbooth/request/collection_spec.rb +104 -0
  107. data/spec/redbooth/request/connection_spec.rb +82 -0
  108. data/spec/redbooth/request/info_spec.rb +27 -0
  109. data/spec/redbooth/request/response_spec.rb +32 -0
  110. data/spec/redbooth/request/validator_spec.rb +45 -0
  111. data/spec/redbooth/task_spec.rb +90 -0
  112. data/spec/redbooth/user_spec.rb +32 -0
  113. data/spec/redbooth_spec.rb +69 -0
  114. data/spec/shared/authentication_context.rb +24 -0
  115. data/spec/spec_helper.rb +22 -0
  116. metadata +370 -0
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://localhost:3000/api/3/tasks/2
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=new+test+name
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Authorization:
13
+ - Bearer _frank_access_token_
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ X-Ua-Compatible:
28
+ - IE=Edge,chrome=1
29
+ Etag:
30
+ - '"46891fc83ef0e7277106053a60e4c4cd"'
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - d65e008c7e939123addaf3b7f9cb6b53
35
+ X-Runtime:
36
+ - '0.264961'
37
+ Connection:
38
+ - close
39
+ Server:
40
+ - thin 1.6.1 codename Death Proof
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"type":"Task","created_at":1415002297,"updated_at":1415018721,"id":2,"name":"new
44
+ test name","task_list_id":2,"comments_count":2,"assigned_id":null,"is_private":false,"project_id":2,"urgent":false,"user_id":1,"position":1,"last_activity_id":53,"record_conversion_type":null,"record_conversion_id":null,"metadata":{},"subtasks_count":0,"resolved_subtasks_count":0,"watcher_ids":[1,5],"description":null,"description_html":"","description_updated_by_user_id":null,"updated_by_id":1,"deleted":false,"row_order":4194304,"status":"open","due_on":null}'
45
+ http_version:
46
+ recorded_at: Mon, 03 Nov 2014 12:45:21 GMT
47
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://localhost:3000/api/3/tasks/2
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=new+test+name
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Authorization:
13
+ - Bearer _frank_access_token_
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ X-Ua-Compatible:
28
+ - IE=Edge,chrome=1
29
+ Etag:
30
+ - '"0e3be7c448f738743eb10060f29859bc"'
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - 7da27323809d57a69768856ab3aed516
35
+ X-Runtime:
36
+ - '0.347134'
37
+ Connection:
38
+ - close
39
+ Server:
40
+ - thin 1.6.1 codename Death Proof
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"type":"Task","created_at":1415002297,"updated_at":1415018489,"id":2,"name":"new
44
+ test name","task_list_id":2,"comments_count":2,"assigned_id":null,"is_private":false,"project_id":2,"urgent":false,"user_id":1,"position":1,"last_activity_id":53,"record_conversion_type":null,"record_conversion_id":null,"metadata":{},"subtasks_count":0,"resolved_subtasks_count":0,"watcher_ids":[1,5],"description":null,"description_html":"","description_updated_by_user_id":null,"updated_by_id":1,"deleted":false,"row_order":4194304,"status":"open","due_on":null}'
45
+ http_version:
46
+ recorded_at: Mon, 03 Nov 2014 12:41:29 GMT
47
+ recorded_with: VCR 2.9.3
@@ -0,0 +1 @@
1
+ loremp ipsum dolor loremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolorloremp ipsum dolor...
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Base do
4
+ describe "#parse_timestamps" do
5
+ context "given #created_time is present" do
6
+ it "creates a Time object" do
7
+ base = Redbooth::Base.new(created_time: 1358300444)
8
+ expect(base.created_time.class).to eql(Time)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,69 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Client do
4
+ let(:consumer_key) { '_your_consumen_key_' }
5
+ let(:consumer_secret) { '_your_consumen_secret_' }
6
+ let(:access_token) do
7
+ {
8
+ token: '_your_user_token_',
9
+ secret: '_your_secret_token_'
10
+ }
11
+ end
12
+ let(:client) { Redbooth::Client.new(session) }
13
+ let(:session) { Redbooth::Session.new(access_token) }
14
+ let(:valid_attributes) { JSON.parse('{}') }
15
+
16
+ before :each do
17
+ allow(Redbooth).to receive(:request).and_return(valid_attributes)
18
+ end
19
+
20
+ describe '#initialize' do
21
+ it 'initializes attributes correctly' do
22
+ expect(client.session).to eql(session)
23
+ end
24
+ it 'raises Redbooth::AuthenticationError if session is invalid' do
25
+ allow(session).to receive(:valid?).and_return(false)
26
+
27
+ expect{client}.to raise_error{ Redbooth::AuthenticationError }
28
+ end
29
+ end
30
+
31
+ describe '#perform!' do
32
+ it 'is private' do
33
+ expect{client.perform!(:user, :show)}.to raise_error
34
+ end
35
+ it 'raises Redbooth::AuthenticationError if session is invalid' do
36
+ allow(client).to receive(:session).and_return(nil)
37
+ expect{client.perform!(:user, :show)}.to raise_error{ Redbooth::AuthenticationError }
38
+ end
39
+ it 'calls to the given resource' do
40
+ allow(Redbooth::User).to receive(:show).and_return(Redbooth::User.new)
41
+ expect(Redbooth::User).to receive(:show).with({ session: session })
42
+
43
+ client.send(:perform!, :user, :show)
44
+ end
45
+ end
46
+
47
+ describe '#options_with_session' do
48
+ it 'is private' do
49
+ expect{client.options_with_session({})}.to raise_error
50
+ end
51
+ it 'adds the session to the given options' do
52
+ expect(client.send(:options_with_session,{})).to include(:session)
53
+ expect(client.send(:options_with_session,{})[:session]).to eql(session)
54
+ end
55
+ end
56
+
57
+ describe '#resource' do
58
+ it 'is private' do
59
+ expect{client.resource('user')}.to raise_error
60
+ end
61
+ it 'gives the correct api resource class' do
62
+ expect(client.send(:resource, 'user')).to eql(Redbooth::User)
63
+ end
64
+ it 'gives nil if there is no resource for the given name' do
65
+ expect(client.send(:resource, 'icecream')).to be_nil
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Me, vcr: 'me' do
4
+ include_context 'authentication'
5
+ let(:me) { client.me(:show) }
6
+ let(:response) { double(:response, data: {})}
7
+
8
+ describe '#initialize' do
9
+ subject { me }
10
+
11
+ it { expect(subject.email).to eql('example_frank@redbooth.com') }
12
+ it { expect(subject.id).to eql(1) }
13
+ it { expect(subject.first_name).to eql('Frank') }
14
+ it { expect(subject.last_name).to eql('Kramer') }
15
+ end
16
+
17
+ describe '.show' do
18
+ subject { me }
19
+
20
+ it 'makes a new GET request using the correct API endpoint to receive a specific user' do
21
+ expect(Redbooth).to receive(:request).with(:get, nil, 'me', {}, { session: session }).and_call_original
22
+ subject
23
+ end
24
+
25
+ it { expect(subject.email).to eql('example_frank@redbooth.com') }
26
+ it { expect(subject.id).to eql(1) }
27
+ it { expect(subject.first_name).to eql('Frank') }
28
+ it { expect(subject.last_name).to eql('Kramer') }
29
+ end
30
+
31
+ describe '#update' do
32
+ let(:update_attributes) { { first_name: 'new_first_name' } }
33
+ subject { client.me(:update, update_attributes) }
34
+
35
+ it 'makes a new PUT request using the correct API endpoint' do
36
+ expect(Redbooth).to receive(:request).with(:put, nil, 'me', update_attributes, { session: session }).and_return(response)
37
+ subject
38
+ end
39
+
40
+ context 'integration' do
41
+ after(:each) { client.me(:update, first_name: 'Frank') }
42
+
43
+ it { expect(subject.first_name).to eql('new_first_name') }
44
+ end
45
+ end
46
+
47
+ describe '#delete' do
48
+ subject { client.me(:delete) }
49
+
50
+ it 'makes a new DELETE request using the correct API endpoint' do
51
+ expect(Redbooth).to receive(:request).with(:delete, nil, 'me', {}, { session: session })
52
+
53
+ subject
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,80 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Organization, vcr: 'organization' do
4
+ include_context 'authentication'
5
+
6
+ let(:create_organization_params) do
7
+ { name: 'new Organization' }
8
+ end
9
+ let(:new_organization) { client.organization(:create, create_organization_params.merge(session: session)) }
10
+ let(:organization) do
11
+ client.organization(:show, id: 1)
12
+ end
13
+
14
+ describe "#initialize" do
15
+ subject { organization }
16
+
17
+ it { expect(subject.id).to eql 1 }
18
+ it { expect(subject.name).to eql 'Design projects' }
19
+ it { expect(subject.permalink).to eql 'design-projects' }
20
+ it { expect(subject.domain).to eql nil }
21
+ end
22
+
23
+ describe ".show" do
24
+ subject { organization }
25
+
26
+ it "makes a new GET request using the correct API endpoint to receive a specific organization" do
27
+ expect(Redbooth).to receive(:request).with(:get, nil, "organizations/1", {}, { session: session }).and_call_original
28
+ subject
29
+ end
30
+
31
+ it { expect(subject.id).to eql 1 }
32
+ it { expect(subject.name).to eql 'Design projects' }
33
+ it { expect(subject.permalink).to eql 'design-projects' }
34
+ it { expect(subject.domain).to eql nil }
35
+ end
36
+
37
+ describe ".update" do
38
+ subject { client.organization(:update, id: 2, name: 'new test name') }
39
+
40
+ it "makes a new PUT request using the correct API endpoint to receive a specific organization" do
41
+ expect(Redbooth).to receive(:request).with(:put, nil, "organizations/2", { name: 'new test name' }, { session: session }).and_call_original
42
+ subject
43
+ end
44
+
45
+ it { expect(subject.name).to eql 'new test name' }
46
+ it { expect(subject.id).to eql 2 }
47
+ end
48
+
49
+ describe ".create" do
50
+ subject { new_organization }
51
+
52
+ it "makes a new POST request using the correct API endpoint to create a specific organization" do
53
+ expect(Redbooth).to receive(:request).with(:post, nil, "organizations", create_organization_params, { session: session }).and_call_original
54
+ subject
55
+ end
56
+
57
+ it { expect(subject.name).to eql 'new Organization' }
58
+ end
59
+
60
+ describe ".delete" do
61
+ subject { client.organization(:delete, id: new_organization.id) }
62
+ before { allow_any_instance_of(Redbooth::Client).to receive(:sleep) }
63
+
64
+ it "makes a new DELETE request using the correct API endpoint to delete a specific organization" do
65
+ expect(Redbooth).to receive(:request).with(:delete, nil, "organizations/#{new_organization.id}", {}, { session: session }).twice.and_call_original
66
+ subject
67
+ end
68
+ end
69
+
70
+ describe ".index" do
71
+ subject { client.organization(:index) }
72
+
73
+ it "makes a new PUT request using the correct API endpoint to receive a specific organization" do
74
+ expect(Redbooth).to receive(:request).with(:get, nil, "organizations", {}, { session: session }).and_call_original
75
+ subject
76
+ end
77
+
78
+ it { expect(subject.class).to eql Redbooth::Request::Collection }
79
+ end
80
+ end
@@ -0,0 +1,85 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Person, vcr: 'person' do
4
+ include_context 'authentication'
5
+
6
+ let(:create_params) do
7
+ { project_id: 1,
8
+ user_id: 3,
9
+ role: 'participant' }
10
+ end
11
+ let(:endpoint_name) { 'people' }
12
+ let(:new_person) { client.person(:create, create_params.merge(session: session)) }
13
+ let(:person) do
14
+ client.person(:show, id: 1)
15
+ end
16
+
17
+ describe "#initialize" do
18
+ subject { person }
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 { person }
27
+
28
+ it "makes a new GET request using the correct API endpoint to receive a specific person" do
29
+ expect(Redbooth).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.person(:update, id: 6, role: 'admin') }
40
+
41
+ it "makes a new PUT request using the correct API endpoint to receive a specific person" do
42
+ expect(Redbooth).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_person }
52
+ let(:response) { double(:response, data: {} )}
53
+
54
+ it "makes a new POST request using the correct API endpoint to create a specific person" do
55
+ expect(Redbooth).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.person(: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.person(:delete, id: new_person.id) }
68
+
69
+ it "makes a new DELETE request using the correct API endpoint to delete a specific person" do
70
+ expect(Redbooth).to receive(:request).with(:delete, nil, "#{endpoint_name}/#{new_person.id}", {}, { session: session }).and_call_original
71
+ subject
72
+ end
73
+ end
74
+
75
+ describe ".index" do
76
+ subject { client.person(:index) }
77
+
78
+ it "makes a new PUT request using the correct API endpoint to receive a specific person" do
79
+ expect(Redbooth).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 Redbooth::Request::Collection }
84
+ end
85
+ end
@@ -0,0 +1,80 @@
1
+ require "spec_helper"
2
+
3
+ describe Redbooth::Project, vcr: 'project' do
4
+ include_context 'authentication'
5
+
6
+ let(:create_params) do
7
+ { name: 'new Project',
8
+ organization_id: 1 }
9
+ end
10
+ let(:new_project) { client.project(:create, create_params.merge(session: session)) }
11
+ let(:endpoint_name) { 'projects' }
12
+ let(:project) do
13
+ client.project(:show, id: 1)
14
+ end
15
+
16
+ describe "#initialize" do
17
+ subject { project }
18
+
19
+ it { expect(subject.id).to eql 1 }
20
+ it { expect(subject.name).to eql 'General' }
21
+ it { expect(subject.permalink).to eql 'general' }
22
+ end
23
+
24
+ describe ".show" do
25
+ subject { project }
26
+
27
+ it "makes a new GET request using the correct API endpoint to receive a specific project" do
28
+ expect(Redbooth).to receive(:request).with(:get, nil, "#{endpoint_name}/1", {}, { session: session }).and_call_original
29
+ subject
30
+ end
31
+
32
+ it { expect(subject.id).to eql 1 }
33
+ it { expect(subject.name).to eql 'General' }
34
+ it { expect(subject.permalink).to eql 'general' }
35
+ end
36
+
37
+ describe ".update" do
38
+ subject { client.project(:update, id: 2, name: 'new test name') }
39
+
40
+ it "makes a new PUT request using the correct API endpoint to receive a specific project" do
41
+ expect(Redbooth).to receive(:request).with(:put, nil, "#{endpoint_name}/2", { name: 'new test name' }, { session: session }).and_call_original
42
+ subject
43
+ end
44
+
45
+ it { expect(subject.name).to eql 'new test name' }
46
+ it { expect(subject.id).to eql 2 }
47
+ end
48
+
49
+ describe ".create" do
50
+ subject { new_project }
51
+
52
+ it "makes a new POST request using the correct API endpoint to create a specific project" do
53
+ expect(Redbooth).to receive(:request).with(:post, nil, "#{endpoint_name}", create_params, { session: session }).and_call_original
54
+ subject
55
+ end
56
+
57
+ it { expect(subject.name).to eql 'new Project' }
58
+ end
59
+
60
+ describe ".delete" do
61
+ subject { client.project(:delete, id: new_project.id) }
62
+ before { allow_any_instance_of(Redbooth::Client).to receive(:sleep) }
63
+
64
+ it "makes a new DELETE request using the correct API endpoint to delete a specific project" do
65
+ expect(Redbooth).to receive(:request).with(:delete, nil, "#{endpoint_name}/#{new_project.id}", {}, { session: session }).at_least(:twice).and_call_original
66
+ subject
67
+ end
68
+ end
69
+
70
+ describe ".index" do
71
+ subject { client.project(:index) }
72
+
73
+ it "makes a new PUT request using the correct API endpoint to receive a specific project" do
74
+ expect(Redbooth).to receive(:request).with(:get, nil, "#{endpoint_name}", {}, { session: session }).and_call_original
75
+ subject
76
+ end
77
+
78
+ it { expect(subject.class).to eql Redbooth::Request::Collection }
79
+ end
80
+ end