redbooth-ruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +237 -20
  3. data/lib/redbooth-ruby.rb +10 -0
  4. data/lib/redbooth-ruby/base.rb +1 -1
  5. data/lib/redbooth-ruby/client.rb +9 -2
  6. data/lib/redbooth-ruby/client_operations/metadata.rb +32 -0
  7. data/lib/redbooth-ruby/client_operations/search.rb +32 -0
  8. data/lib/redbooth-ruby/comment.rb +34 -0
  9. data/lib/redbooth-ruby/file.rb +68 -0
  10. data/lib/redbooth-ruby/note.rb +25 -0
  11. data/lib/redbooth-ruby/operations/create.rb +1 -1
  12. data/lib/redbooth-ruby/operations/index.rb +0 -12
  13. data/lib/redbooth-ruby/operations/meta.rb +33 -2
  14. data/lib/redbooth-ruby/operations/show.rb +1 -1
  15. data/lib/redbooth-ruby/request/collection.rb +37 -5
  16. data/lib/redbooth-ruby/request/connection.rb +14 -8
  17. data/lib/redbooth-ruby/request/validator.rb +32 -4
  18. data/lib/redbooth-ruby/subtask.rb +18 -0
  19. data/lib/redbooth-ruby/task.rb +1 -1
  20. data/lib/redbooth-ruby/version.rb +1 -1
  21. data/redbooth-ruby.gemspec +1 -0
  22. data/spec/cassettes/RedboothRuby_ClientOperations_Metadata/_metadata/.yml +55 -0
  23. data/spec/cassettes/RedboothRuby_ClientOperations_Metadata/_metadata/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +55 -0
  24. data/spec/cassettes/RedboothRuby_ClientOperations_Search/_index/.yml +271 -0
  25. data/spec/cassettes/RedboothRuby_ClientOperations_Search/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +271 -0
  26. data/spec/cassettes/RedboothRuby_Comment/_create/.yml +47 -0
  27. data/spec/cassettes/RedboothRuby_Comment/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_comment.yml +47 -0
  28. data/spec/cassettes/RedboothRuby_Comment/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml +84 -0
  29. data/spec/cassettes/RedboothRuby_Comment/_index/.yml +94 -0
  30. data/spec/cassettes/RedboothRuby_Comment/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml +94 -0
  31. data/spec/cassettes/RedboothRuby_Comment/_initialize/.yml +65 -0
  32. data/spec/cassettes/RedboothRuby_Comment/_show/.yml +65 -0
  33. data/spec/cassettes/RedboothRuby_Comment/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_comment.yml +65 -0
  34. data/spec/cassettes/RedboothRuby_Comment/_update/.yml +47 -0
  35. data/spec/cassettes/RedboothRuby_Comment/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_comment.yml +47 -0
  36. data/spec/cassettes/RedboothRuby_File/_create/.yml +65 -0
  37. data/spec/cassettes/RedboothRuby_File/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_file.yml +65 -0
  38. data/spec/cassettes/RedboothRuby_File/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml +102 -0
  39. data/spec/cassettes/RedboothRuby_File/_index/.yml +58 -0
  40. data/spec/cassettes/RedboothRuby_File/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml +58 -0
  41. data/spec/cassettes/RedboothRuby_File/_initialize/.yml +44 -0
  42. data/spec/cassettes/RedboothRuby_File/_show/.yml +44 -0
  43. data/spec/cassettes/RedboothRuby_File/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_file.yml +44 -0
  44. data/spec/cassettes/RedboothRuby_File/_update/.yml +46 -0
  45. data/spec/cassettes/RedboothRuby_File/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_file.yml +46 -0
  46. data/spec/cassettes/RedboothRuby_Note/_create/.yml +47 -0
  47. data/spec/cassettes/RedboothRuby_Note/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_note.yml +47 -0
  48. data/spec/cassettes/RedboothRuby_Note/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_note.yml +84 -0
  49. data/spec/cassettes/RedboothRuby_Note/_index/.yml +193 -0
  50. data/spec/cassettes/RedboothRuby_Note/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +193 -0
  51. data/spec/cassettes/RedboothRuby_Note/_initialize/.yml +109 -0
  52. data/spec/cassettes/RedboothRuby_Note/_show/.yml +109 -0
  53. data/spec/cassettes/RedboothRuby_Note/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_note.yml +109 -0
  54. data/spec/cassettes/RedboothRuby_Note/_update/.yml +73 -0
  55. data/spec/cassettes/RedboothRuby_Note/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_note.yml +73 -0
  56. data/spec/cassettes/RedboothRuby_Subtask/_create/.yml +47 -0
  57. data/spec/cassettes/RedboothRuby_Subtask/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_subtask.yml +47 -0
  58. data/spec/cassettes/RedboothRuby_Subtask/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_subtask.yml +84 -0
  59. data/spec/cassettes/RedboothRuby_Subtask/_index/.yml +99 -0
  60. data/spec/cassettes/RedboothRuby_Subtask/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_subtasks_collection.yml +99 -0
  61. data/spec/cassettes/RedboothRuby_Subtask/_initialize/.yml +45 -0
  62. data/spec/cassettes/RedboothRuby_Subtask/_show/.yml +45 -0
  63. data/spec/cassettes/RedboothRuby_Subtask/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_subtask.yml +45 -0
  64. data/spec/cassettes/RedboothRuby_Subtask/_update/.yml +47 -0
  65. data/spec/cassettes/RedboothRuby_Subtask/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_subtask.yml +47 -0
  66. data/spec/cassettes/RedboothRuby_Task/_medatada/.yml +88 -0
  67. data/spec/cassettes/RedboothRuby_Task/_medatada/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +88 -0
  68. data/spec/cassettes/RedboothRuby_Task/_medatada_/.yml +90 -0
  69. data/spec/cassettes/RedboothRuby_Task/_medatada_/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +90 -0
  70. data/spec/cassettes/RedboothRuby_Task/_metadata_merge/.yml +133 -0
  71. data/spec/cassettes/RedboothRuby_Task/_metadata_merge/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +133 -0
  72. data/spec/redbooth-ruby/client_operations/metadata_spec.rb +24 -0
  73. data/spec/redbooth-ruby/client_operations/search_spec.rb +24 -0
  74. data/spec/redbooth-ruby/comment_spec.rb +87 -0
  75. data/spec/redbooth-ruby/file_spec.rb +89 -0
  76. data/spec/redbooth-ruby/note_spec.rb +84 -0
  77. data/spec/redbooth-ruby/subtaks_spec.rb +83 -0
  78. data/spec/redbooth-ruby/task_spec.rb +41 -0
  79. data/spec/spec_helper.rb +2 -0
  80. metadata +134 -2
@@ -0,0 +1,133 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3000/api/3/tasks/1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Authorization:
13
+ - Bearer _frank_access_token_
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Ua-Compatible:
26
+ - IE=Edge,chrome=1
27
+ Etag:
28
+ - '"995d617c5d5d4edaa253f4ee352507ee"'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ X-Request-Id:
32
+ - f506705ca073e33b9a0c7cccd0bc4326
33
+ X-Runtime:
34
+ - '0.124034'
35
+ Connection:
36
+ - close
37
+ Server:
38
+ - thin 1.6.1 codename Death Proof
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"type":"Task","created_at":1415624550,"updated_at":1415629595,"id":1,"name":"Register
42
+ all EarthworksYoga TLDs","task_list_id":2,"comments_count":2,"assigned_id":8,"is_private":false,"project_id":2,"urgent":false,"user_id":3,"position":0,"last_activity_id":null,"record_conversion_type":null,"record_conversion_id":null,"metadata":{},"subtasks_count":7,"resolved_subtasks_count":2,"watcher_ids":[3,4],"description":"The
43
+ ships hung in the sky in much the same way that bricks don''t.","description_html":"<p>The
44
+ ships hung in the sky in much the same way that bricks don''t.</p>","description_updated_by_user_id":3,"updated_by_id":4,"deleted":false,"row_order":0,"status":"resolved","due_on":"2014-11-11"}'
45
+ http_version:
46
+ recorded_at: Fri, 14 Nov 2014 16:50:31 GMT
47
+ - request:
48
+ method: post
49
+ uri: http://localhost:3000/api/3/metadata
50
+ body:
51
+ encoding: UTF-8
52
+ string: metadata%5Bnew%5D=metadata&metadata%5Bother%5D=value&target_id=1&target_type=Task
53
+ headers:
54
+ User-Agent:
55
+ - Faraday v0.9.0
56
+ Authorization:
57
+ - Bearer _frank_access_token_
58
+ Content-Type:
59
+ - application/x-www-form-urlencoded
60
+ Accept-Encoding:
61
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
62
+ Accept:
63
+ - '*/*'
64
+ response:
65
+ status:
66
+ code: 201
67
+ message: Created
68
+ headers:
69
+ Content-Type:
70
+ - application/json; charset=utf-8
71
+ X-Ua-Compatible:
72
+ - IE=Edge,chrome=1
73
+ Etag:
74
+ - '"eb591be1adacc68e1b6631375add1186"'
75
+ Cache-Control:
76
+ - max-age=0, private, must-revalidate
77
+ X-Request-Id:
78
+ - 2a78d490925362db58d2ac95f3e0eceb
79
+ X-Runtime:
80
+ - '0.108446'
81
+ Connection:
82
+ - close
83
+ Server:
84
+ - thin 1.6.1 codename Death Proof
85
+ body:
86
+ encoding: UTF-8
87
+ string: '{"new":"metadata","other":"value"}'
88
+ http_version:
89
+ recorded_at: Fri, 14 Nov 2014 16:50:31 GMT
90
+ - request:
91
+ method: put
92
+ uri: http://localhost:3000/api/3/metadata
93
+ body:
94
+ encoding: UTF-8
95
+ string: metadata%5Bother%5D=updated_value&target_id=1&target_type=Task
96
+ headers:
97
+ User-Agent:
98
+ - Faraday v0.9.0
99
+ Authorization:
100
+ - Bearer _frank_access_token_
101
+ Content-Type:
102
+ - application/x-www-form-urlencoded
103
+ Accept-Encoding:
104
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
105
+ Accept:
106
+ - '*/*'
107
+ response:
108
+ status:
109
+ code: 200
110
+ message: OK
111
+ headers:
112
+ Content-Type:
113
+ - application/json; charset=utf-8
114
+ X-Ua-Compatible:
115
+ - IE=Edge,chrome=1
116
+ Etag:
117
+ - '"c494d65897a7ed4d58f1da02d0b2c447"'
118
+ Cache-Control:
119
+ - max-age=0, private, must-revalidate
120
+ X-Request-Id:
121
+ - a6edb66d6e8f32763823d2f8faf336bf
122
+ X-Runtime:
123
+ - '0.145040'
124
+ Connection:
125
+ - close
126
+ Server:
127
+ - thin 1.6.1 codename Death Proof
128
+ body:
129
+ encoding: UTF-8
130
+ string: '{"new":"metadata","other":"updated_value"}'
131
+ http_version:
132
+ recorded_at: Fri, 14 Nov 2014 16:51:06 GMT
133
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe RedboothRuby::ClientOperations::Metadata, vcr: 'metadata' do
4
+ include_context 'authentication'
5
+
6
+ let(:search_params) do
7
+ { target_type: 'Task',
8
+ key: 'new',
9
+ value: 'metadata' }
10
+ end
11
+ let(:endpoint) { 'metadata/search' }
12
+
13
+ describe ".metadata" do
14
+ subject { client.metadata(search_params) }
15
+
16
+ it "makes a new GET request using the correct API endpoint to receive notes collection" do
17
+ expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, search_params, { session: session }).and_call_original
18
+ subject
19
+ end
20
+
21
+ it { expect(subject.class).to eql RedboothRuby::Request::Collection }
22
+ it { expect(subject.all.first).to be_a RedboothRuby::Base }
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe RedboothRuby::ClientOperations::Search, vcr: 'search' do
4
+ include_context 'authentication'
5
+
6
+ let(:search_params) do
7
+ { project_id: 2,
8
+ name: 'new created note',
9
+ content: 'bla bla bla' }
10
+ end
11
+ let(:endpoint) { 'search' }
12
+
13
+ describe ".index" do
14
+ subject { client.search(query: 'task') }
15
+
16
+ it "makes a new GET request using the correct API endpoint to receive notes collection" do
17
+ expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, { query: 'task' }, { session: session }).and_call_original
18
+ subject
19
+ end
20
+
21
+ it { expect(subject.class).to eql RedboothRuby::Request::Collection }
22
+ it { expect(subject.all.first).to be_a RedboothRuby::Base }
23
+ end
24
+ end
@@ -0,0 +1,87 @@
1
+ # Encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe RedboothRuby::Comment, vcr: 'comments' do
5
+ include_context 'authentication'
6
+
7
+ let(:create_params) do
8
+ { project_id: 2,
9
+ target_type: 'Conversation',
10
+ target_id: 2,
11
+ body: 'new created comment' }
12
+ end
13
+ let(:new_record) { client.comment(:create, create_params) }
14
+ let(:endpoint) { 'comments' }
15
+ let(:comment) do
16
+ client.comment(:show, id: 1)
17
+ end
18
+
19
+ describe "#initialize" do
20
+ subject { comment }
21
+
22
+ it { expect(subject.id).to eql 1 }
23
+ it { expect(subject.body).to eql "Hey guys. I\’m looking forward to working with you all again. I\’m also pleased to be working with my friend and yoga instructor Marco Fizzulo. This should be straightforward project and I can\’t wait to see what we put together." }
24
+ it { expect(subject.project_id).to eql 2 }
25
+ it { expect(subject.target_id).to eql 1 }
26
+ it { expect(subject.target_type).to eql 'Conversation' }
27
+ it { expect(subject.is_private).to eql false }
28
+ end
29
+
30
+ describe ".show" do
31
+ subject { comment }
32
+
33
+ it "makes a new GET request using the correct API endpoint to receive a specific comment" do
34
+ expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint}/1", {}, { session: session }).and_call_original
35
+ subject
36
+ end
37
+
38
+ it { expect(subject.id).to eql 1 }
39
+ it { expect(subject.body).to eql "Hey guys. I\’m looking forward to working with you all again. I\’m also pleased to be working with my friend and yoga instructor Marco Fizzulo. This should be straightforward project and I can\’t wait to see what we put together." }
40
+ it { expect(subject.project_id).to eql 2 }
41
+ end
42
+
43
+ describe ".update" do
44
+ subject { client.comment(:update, id: 24, body: 'new test body') }
45
+
46
+ it "makes a new PUT request using the correct API endpoint to receive a specific comment" do
47
+ expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint}/24", { body: 'new test body' }, { session: session }).and_call_original
48
+ subject
49
+ end
50
+
51
+ it { expect(subject.body).to eql 'new test body' }
52
+ it { expect(subject.id).to eql 24 }
53
+ end
54
+
55
+ describe ".create" do
56
+ subject { new_record }
57
+
58
+ it "makes a new POST request using the correct API endpoint to create a specific comment" do
59
+ expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params, { session: session }).and_call_original
60
+ subject
61
+ end
62
+
63
+ it { expect(subject.body).to eql 'new created comment' }
64
+ it { expect(subject.project_id).to eql 2 }
65
+ it { expect(subject.user_id).to eql 1 }
66
+ end
67
+
68
+ describe ".delete" do
69
+ subject { client.comment(:delete, id: new_record.id) }
70
+
71
+ it "makes a new DELETE request using the correct API endpoint to delete a specific comment" do
72
+ expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint}/#{new_record.id}", {}, { session: session }).and_call_original
73
+ subject
74
+ end
75
+ end
76
+
77
+ describe ".index" do
78
+ subject { client.comment(:index, target_type: 'Task', target_id: 1) }
79
+
80
+ it "makes a new GET request using the correct API endpoint to receive comments collection" do
81
+ expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, {target_type: 'Task', target_id: 1}, { session: session }).and_call_original
82
+ subject
83
+ end
84
+
85
+ it { expect(subject.class).to eql RedboothRuby::Request::Collection }
86
+ end
87
+ end
@@ -0,0 +1,89 @@
1
+ # Encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe RedboothRuby::File, vcr: 'files' do
5
+ include_context 'authentication'
6
+
7
+ let(:create_params) do
8
+ { project_id: 2,
9
+ backend: 'redbooth',
10
+ asset: File.open("#{File.dirname(__FILE__)}/../fixtures/hola.txt") }
11
+ end
12
+ let(:new_record) { client.file(:create, create_params) }
13
+ let(:endpoint) { 'files' }
14
+ let(:file) do
15
+ client.file(:show, id: 1)
16
+ end
17
+
18
+ describe "#initialize" do
19
+ subject { file }
20
+
21
+ it { expect(subject.id).to eql 1 }
22
+ it { expect(subject.name).to eql "Reports" }
23
+ it { expect(subject.project_id).to eql 2 }
24
+ it { expect(subject.parent_id).to eql nil }
25
+ it { expect(subject.pinned).to eql false }
26
+ end
27
+
28
+ describe ".show" do
29
+ subject { file }
30
+
31
+ it "makes a new GET request using the correct API endpoint to receive a specific file" do
32
+ expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint}/1", {}, { session: session }).and_call_original
33
+ subject
34
+ end
35
+
36
+ it { expect(subject.id).to eql 1 }
37
+ it { expect(subject.name).to eql "Reports" }
38
+ it { expect(subject.project_id).to eql 2 }
39
+ end
40
+
41
+ describe ".update" do
42
+ subject { client.file(:update, id: 2, name: 'new_name.txt') }
43
+
44
+ it "makes a new PUT request using the correct API endpoint to receive a specific file" do
45
+ expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint}/2", { name: 'new_name.txt' }, { session: session }).and_call_original
46
+ subject
47
+ end
48
+
49
+ it { expect(subject.name).to eql 'new_name.txt' }
50
+ it { expect(subject.id).to eql 2 }
51
+ end
52
+
53
+ describe ".create" do
54
+ subject { new_record }
55
+ let(:asset_params) {
56
+ { asset_attrs: { name: "hola.txt", local_path: "#{File.dirname(__FILE__)}/../fixtures/hola.txt"} }
57
+ }
58
+
59
+ it "makes a new POST request using the correct API endpoint to create a specific file" do
60
+ expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params.merge(asset_params) , { session: session }).and_call_original
61
+ subject
62
+ end
63
+
64
+ it { expect(subject.name).to eql 'hola.txt' }
65
+ it { expect(subject.backend).to eql 'redbooth' }
66
+ it { expect(subject.project_id).to eql 2 }
67
+ it { expect(subject.user_id).to eql 1 }
68
+ end
69
+
70
+ describe ".delete" do
71
+ subject { client.file(:delete, id: new_record.id) }
72
+
73
+ it "makes a new DELETE request using the correct API endpoint to delete a specific comment" do
74
+ expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint}/#{new_record.id}", {}, { session: session }).and_call_original
75
+ subject
76
+ end
77
+ end
78
+
79
+ describe ".index" do
80
+ subject { client.file(:index, project_id: 1) }
81
+
82
+ it "makes a new GET request using the correct API endpoint to receive comments collection" do
83
+ expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, {project_id: 1}, { session: session }).and_call_original
84
+ subject
85
+ end
86
+
87
+ it { expect(subject.class).to eql RedboothRuby::Request::Collection }
88
+ end
89
+ end
@@ -0,0 +1,84 @@
1
+ require "spec_helper"
2
+
3
+ describe RedboothRuby::Note, vcr: 'notes' do
4
+ include_context 'authentication'
5
+
6
+ let(:create_params) do
7
+ { project_id: 2,
8
+ name: 'new created note',
9
+ content: 'bla bla bla' }
10
+ end
11
+ let(:new_record) { client.note(:create, create_params) }
12
+ let(:endpoint) { 'notes' }
13
+ let(:note) do
14
+ client.note(:show, id: 1)
15
+ end
16
+
17
+ describe "#initialize" do
18
+ subject { note }
19
+
20
+ it { expect(subject.id).to eql 1 }
21
+ it { expect(subject.name).to eql 'Site content' }
22
+ it { expect(subject.project_id).to eql 2 }
23
+ it { expect(subject.permalink).to eql 'site-content' }
24
+ it { expect(subject.is_private).to eql false }
25
+ end
26
+
27
+ describe ".show" do
28
+ subject { note }
29
+
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
+ subject
33
+ end
34
+
35
+ it { expect(subject.id).to eql 1 }
36
+ it { expect(subject.name).to eql 'Site content' }
37
+ it { expect(subject.project_id).to eql 2 }
38
+ end
39
+
40
+ describe ".update" do
41
+ subject { client.note(:update, id: 2, name: 'new test name') }
42
+
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
+ subject
46
+ end
47
+
48
+ it { expect(subject.name).to eql 'new test name' }
49
+ it { expect(subject.id).to eql 2 }
50
+ end
51
+
52
+ describe ".create" do
53
+ subject { new_record }
54
+
55
+ it "makes a new POST request using the correct API endpoint to create a specific note" do
56
+ expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params, { session: session }).and_call_original
57
+ subject
58
+ end
59
+
60
+ it { expect(subject.name).to eql 'new created note' }
61
+ it { expect(subject.project_id).to eql 2 }
62
+ it { expect(subject.user_id).to eql 1 }
63
+ end
64
+
65
+ describe ".delete" do
66
+ subject { client.note(:delete, id: new_record.id) }
67
+
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
+ subject
71
+ end
72
+ end
73
+
74
+ describe ".index" do
75
+ subject { client.note(:index) }
76
+
77
+ it "makes a new GET request using the correct API endpoint to receive notes collection" do
78
+ expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, {}, { session: session }).and_call_original
79
+ subject
80
+ end
81
+
82
+ it { expect(subject.class).to eql RedboothRuby::Request::Collection }
83
+ end
84
+ end