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
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RedboothRuby::Session, vcr: 'session' do
|
4
|
+
let(:token) { '_your_user_token_' }
|
5
|
+
let(:refresh_token) { '_your_user_refresh_token_' }
|
6
|
+
let(:expires_in) { 7200 }
|
7
|
+
let(:auto_refresh_token) { true }
|
8
|
+
let(:consumer_key) { '_your_consumer_key_' }
|
9
|
+
let(:consumer_secret) { '_your_consumer_secret_' }
|
10
|
+
let(:session) do
|
11
|
+
RedboothRuby::Session.new(token: token, refresh_token: refresh_token,
|
12
|
+
expires_in: expires_in, auto_refresh_token: auto_refresh_token,
|
13
|
+
consumer_key: consumer_key, consumer_secret: consumer_secret)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#initialize' do
|
17
|
+
subject { session }
|
18
|
+
|
19
|
+
it { expect(session.token).to eql token }
|
20
|
+
it { expect(session.refresh_token).to eql refresh_token }
|
21
|
+
it { expect(session.expires_in).to eql expires_in }
|
22
|
+
it { expect(session.auto_refresh_token).to eql auto_refresh_token }
|
23
|
+
it { expect(session.consumer_key).to eql consumer_key }
|
24
|
+
it { expect(session.consumer_secret).to eql consumer_secret }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#valid?' do
|
28
|
+
subject { session.valid? }
|
29
|
+
it { should eql true }
|
30
|
+
|
31
|
+
context 'when token is empty' do
|
32
|
+
before { session.token = nil }
|
33
|
+
it { should eql false }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#client' do
|
38
|
+
subject(:client) { session.client }
|
39
|
+
it { should be_a OAuth2::Client }
|
40
|
+
it { expect(client.id).to eql consumer_key }
|
41
|
+
it { expect(client.secret).to eql consumer_secret }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#get_access_token_url' do
|
45
|
+
subject { session.get_access_token_url }
|
46
|
+
it { should eql 'https://redbooth.com/oauth2/token' }
|
47
|
+
|
48
|
+
context 'when oauth_verifier is present' do
|
49
|
+
before { session.oauth_verifier = '_your_user_oauth_verifier_token_' }
|
50
|
+
it { should eql 'https://redbooth.com/oauth2/token?oauth_verifier=_your_user_oauth_verifier_token_' }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when oauth_token is present' do
|
54
|
+
before { session.oauth_token = '_your_user_oauth_token_' }
|
55
|
+
it { should eql 'https://redbooth.com/oauth2/token?oauth_token=_your_user_oauth_token_' }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when oauth_verifier and oauth_token are present' do
|
59
|
+
before do
|
60
|
+
session.oauth_verifier = '_your_user_oauth_verifier_token_'
|
61
|
+
session.oauth_token = '_your_user_oauth_token_'
|
62
|
+
end
|
63
|
+
it { should eql 'https://redbooth.com/oauth2/token?oauth_verifier=_your_user_oauth_verifier_token_&oauth_token=_your_user_oauth_token_' }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#access_token' do
|
68
|
+
subject(:access_token) { session.access_token }
|
69
|
+
it { should be_a OAuth2::AccessToken }
|
70
|
+
it { expect(access_token.client).to eql session.client }
|
71
|
+
it { expect(access_token.token).to eql session.token }
|
72
|
+
it { expect(access_token.refresh_token).to eql session.refresh_token }
|
73
|
+
it { expect(access_token.expires_in).to eql session.expires_in }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#refresh_access_token!' do
|
77
|
+
subject(:access_token) { session.access_token }
|
78
|
+
|
79
|
+
it 'refreshes the access token' do
|
80
|
+
session.refresh_access_token!
|
81
|
+
expect(access_token.token).to eql('_your_new_user_token_')
|
82
|
+
expect(access_token.refresh_token).to eql('_your_new_user_refresh_token_')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'call `on_token_refresh` with the old and new token' do
|
86
|
+
on_token_refresh = Proc.new { |old_token, new_token| }
|
87
|
+
session.on_token_refresh = on_token_refresh
|
88
|
+
|
89
|
+
allow(on_token_refresh).to receive(:call) do |old_token, new_token|
|
90
|
+
expect(old_token.token).to eql('_your_user_token_')
|
91
|
+
expect(old_token.refresh_token).to eql('_your_user_refresh_token_')
|
92
|
+
|
93
|
+
expect(new_token.token).to eql('_your_new_user_token_')
|
94
|
+
expect(new_token.refresh_token).to eql('_your_new_user_refresh_token_')
|
95
|
+
end
|
96
|
+
|
97
|
+
session.refresh_access_token!
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
4
4
|
include_context 'authentication'
|
@@ -14,7 +14,7 @@ describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
|
14
14
|
client.subtask(:show, id: 1)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe '#initialize' do
|
18
18
|
subject { subtask }
|
19
19
|
|
20
20
|
it { expect(subject.id).to eql 1 }
|
@@ -23,11 +23,11 @@ describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
|
23
23
|
it { expect(subject.resolved).to eql true }
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe '.show' do
|
27
27
|
subject { subtask }
|
28
28
|
|
29
|
-
it
|
30
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{endpoint}/1", {}, { session: session }).and_call_original
|
29
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific subtask' do
|
30
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, "#{ endpoint }/1", {}, { session: session }).and_call_original
|
31
31
|
subject
|
32
32
|
end
|
33
33
|
|
@@ -36,11 +36,11 @@ describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
|
36
36
|
it { expect(subject.task_id).to eql 1 }
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
39
|
+
describe '.update' do
|
40
40
|
subject { client.subtask(:update, id: 2, name: 'new test name') }
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{endpoint}/2", { name: 'new test name' }, { session: session }).and_call_original
|
42
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific subtask' do
|
43
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, "#{ endpoint }/2", { name: 'new test name' }, { session: session }).and_call_original
|
44
44
|
subject
|
45
45
|
end
|
46
46
|
|
@@ -48,10 +48,10 @@ describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
|
48
48
|
it { expect(subject.id).to eql 2 }
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
51
|
+
describe '.create' do
|
52
52
|
subject { new_record }
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'makes a new POST request using the correct API endpoint to create a specific subtask' do
|
55
55
|
expect(RedboothRuby).to receive(:request).with(:post, nil, endpoint, create_params, { session: session }).and_call_original
|
56
56
|
subject
|
57
57
|
end
|
@@ -61,23 +61,23 @@ describe RedboothRuby::Subtask, vcr: 'subtasks' do
|
|
61
61
|
it { expect(subject.resolved).to eql false }
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe '.delete' do
|
65
65
|
subject { client.subtask(:delete, id: new_record.id) }
|
66
66
|
|
67
|
-
it
|
68
|
-
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{endpoint}/#{new_record.id}", {}, { session: session }).and_call_original
|
67
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific subtask' do
|
68
|
+
expect(RedboothRuby).to receive(:request).with(:delete, nil, "#{ endpoint }/#{ new_record.id }", {}, { session: session }).and_call_original
|
69
69
|
subject
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
73
|
+
describe '.index' do
|
74
74
|
subject { client.subtask(:index, task_id: 2) }
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'makes a new GET request using the correct API endpoint to receive subtasks collection' do
|
77
77
|
expect(RedboothRuby).to receive(:request).with(:get, nil, endpoint, { task_id: 2 }, { session: session }).and_call_original
|
78
78
|
subject
|
79
79
|
end
|
80
80
|
|
81
81
|
it { expect(subject.class).to eql RedboothRuby::Request::Collection }
|
82
82
|
end
|
83
|
-
end
|
83
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::Task, vcr: 'tasks' do
|
4
4
|
include_context 'authentication'
|
@@ -13,7 +13,7 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
13
13
|
RedboothRuby::Task.show(session: session, id: 1)
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe '#initialize' do
|
17
17
|
subject { task }
|
18
18
|
|
19
19
|
it { expect(subject.id).to eql 1 }
|
@@ -24,9 +24,9 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
24
24
|
it { expect(subject.due_on).to eql '2014-11-04' }
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
28
|
-
it
|
29
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
27
|
+
describe '.show' do
|
28
|
+
it 'makes a new GET request using the correct API endpoint to receive a specific task' do
|
29
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'tasks/1', {}, { session: session }).and_call_original
|
30
30
|
task
|
31
31
|
end
|
32
32
|
it 'returns a task with the correct name' do
|
@@ -43,11 +43,11 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
46
|
+
describe '.update' do
|
47
47
|
subject { RedboothRuby::Task.update(session: session, id: 2, name: 'new test name') }
|
48
48
|
|
49
|
-
it
|
50
|
-
expect(RedboothRuby).to receive(:request).with(:put, nil,
|
49
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific task' do
|
50
|
+
expect(RedboothRuby).to receive(:request).with(:put, nil, 'tasks/2', { name: 'new test name' }, { session: session }).and_call_original
|
51
51
|
subject
|
52
52
|
end
|
53
53
|
|
@@ -55,11 +55,11 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
55
55
|
it { expect(subject.id).to eql 2 }
|
56
56
|
end
|
57
57
|
|
58
|
-
describe
|
58
|
+
describe '.create' do
|
59
59
|
subject { new_task }
|
60
60
|
|
61
|
-
it
|
62
|
-
expect(RedboothRuby).to receive(:request).with(:post, nil,
|
61
|
+
it 'makes a new POST request using the correct API endpoint to create a specific task' do
|
62
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, 'tasks', create_task_params, { session: session }).and_call_original
|
63
63
|
subject
|
64
64
|
end
|
65
65
|
|
@@ -68,20 +68,20 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
68
68
|
it { expect(subject.task_list_id).to eql 3 }
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
71
|
+
describe '.delete' do
|
72
72
|
subject { RedboothRuby::Task.delete(session: session, id: new_task.id) }
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'makes a new DELETE request using the correct API endpoint to delete a specific task' do
|
75
75
|
expect(RedboothRuby).to receive(:request).with(:delete, nil, "tasks/#{new_task.id}", {}, { session: session }).and_call_original
|
76
76
|
subject
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe
|
80
|
+
describe '.index' do
|
81
81
|
subject { RedboothRuby::Task.index(session: session) }
|
82
82
|
|
83
|
-
it
|
84
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
83
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific task' do
|
84
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'tasks', {}, { session: session }).and_call_original
|
85
85
|
subject
|
86
86
|
end
|
87
87
|
|
@@ -91,8 +91,8 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
91
91
|
describe '.medatada' do
|
92
92
|
subject { task.metadata }
|
93
93
|
|
94
|
-
it
|
95
|
-
expect(RedboothRuby).to receive(:request).with(:get, nil,
|
94
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific task' do
|
95
|
+
expect(RedboothRuby).to receive(:request).with(:get, nil, 'metadata', { target_type: 'Task', target_id: task.id }, { session: session }).and_call_original
|
96
96
|
subject
|
97
97
|
end
|
98
98
|
|
@@ -103,8 +103,8 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
103
103
|
describe '.medatada=' do
|
104
104
|
subject { task.metadata = { 'new' => 'metadata' } }
|
105
105
|
|
106
|
-
it
|
107
|
-
expect(RedboothRuby).to receive(:request).with(:post, nil,
|
106
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific task' do
|
107
|
+
expect(RedboothRuby).to receive(:request).with(:post, nil, 'metadata', { target_type: 'Task', target_id: task.id, metadata: { 'new' => 'metadata' } }, { session: session }).and_call_original
|
108
108
|
subject
|
109
109
|
end
|
110
110
|
|
@@ -117,7 +117,7 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
117
117
|
before { task.metadata = { 'new' => 'metadata', 'other' => 'value' } }
|
118
118
|
subject { task.metadata_merge( 'other' => 'updated_value') }
|
119
119
|
|
120
|
-
it
|
120
|
+
it 'makes a new PUT request using the correct API endpoint to receive a specific task' do
|
121
121
|
expect(RedboothRuby).to receive(:request).with(:put, nil, "metadata", { target_type: 'Task', target_id: task.id, metadata: { 'other' => 'updated_value' } }, { session: session }).and_call_original
|
122
122
|
subject
|
123
123
|
end
|
@@ -128,4 +128,4 @@ describe RedboothRuby::Task, vcr: 'tasks' do
|
|
128
128
|
it { expect(subject['new']).to eql 'metadata' }
|
129
129
|
it { expect(subject['other']).to eql 'updated_value' }
|
130
130
|
end
|
131
|
-
end
|
131
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby::User, vcr: 'users' do
|
4
4
|
include_context 'authentication'
|
@@ -7,7 +7,7 @@ describe RedboothRuby::User, vcr: 'users' do
|
|
7
7
|
RedboothRuby::User.show(session: session, id: 1)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe '#initialize' do
|
11
11
|
subject { user }
|
12
12
|
|
13
13
|
it { expect(subject.email).to eql('example_frank@redbooth.com') }
|
@@ -16,7 +16,7 @@ describe RedboothRuby::User, vcr: 'users' do
|
|
16
16
|
it { expect(subject.last_name).to eql('Kramer') }
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe '.show' do
|
20
20
|
subject { RedboothRuby::User.show(session: session, id: 1) }
|
21
21
|
|
22
22
|
it 'makes a new GET request using the correct API endpoint to receive a specific user' do
|
@@ -29,4 +29,4 @@ describe RedboothRuby::User, vcr: 'users' do
|
|
29
29
|
it { expect(subject.first_name).to eql('Frank') }
|
30
30
|
it { expect(subject.last_name).to eql('Kramer') }
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
data/spec/redbooth_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RedboothRuby do
|
4
4
|
describe '.request' do
|
@@ -8,7 +8,7 @@ describe RedboothRuby do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
context
|
11
|
+
context 'with an invalid api key' do
|
12
12
|
let(:consumer_key) { '_your_consumen_key_' }
|
13
13
|
let(:consumer_secret) { '_your_consumen_secret_' }
|
14
14
|
let(:access_token) do
|
@@ -20,7 +20,7 @@ describe RedboothRuby do
|
|
20
20
|
let(:client) { RedboothRuby::Client.new(session) }
|
21
21
|
let(:session) { RedboothRuby::Session.new(access_token) }
|
22
22
|
let(:redbooth_protocol) { RedboothRuby.configuration[:use_ssl] ? 'https' : 'http' }
|
23
|
-
let(:redbooth_url) { "#{redbooth_protocol}://#{RedboothRuby.configuration[:api_base]}/#{RedboothRuby.configuration[:api_base_path]}/#{RedboothRuby.configuration[:api_version]}" }
|
23
|
+
let(:redbooth_url) { "#{ redbooth_protocol }://#{ RedboothRuby.configuration[:api_base] }/#{ RedboothRuby.configuration[:api_base_path] }/#{ RedboothRuby.configuration[:api_version] }" }
|
24
24
|
|
25
25
|
before(:each) do
|
26
26
|
RedboothRuby.config do |configuration|
|
@@ -28,7 +28,7 @@ describe RedboothRuby do
|
|
28
28
|
configuration[:consumer_secret] = consumer_secret
|
29
29
|
end
|
30
30
|
WebMock.stub_request(:any,
|
31
|
-
/#{RedboothRuby.configuration[:api_base]}/
|
31
|
+
/#{ RedboothRuby.configuration[:api_base] }/
|
32
32
|
).to_return(body: '{}')
|
33
33
|
end
|
34
34
|
|
@@ -38,7 +38,7 @@ describe RedboothRuby do
|
|
38
38
|
{ session: session }
|
39
39
|
)
|
40
40
|
expect(WebMock).to have_requested(:get,
|
41
|
-
"#{redbooth_url}/user?param_name=param_value"
|
41
|
+
"#{ redbooth_url }/user?param_name=param_value"
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
@@ -51,19 +51,19 @@ describe RedboothRuby do
|
|
51
51
|
)
|
52
52
|
expect(WebMock).to have_requested(
|
53
53
|
:get,
|
54
|
-
"#{redbooth_url}/user?client=client_id&order=created_at_desc"
|
54
|
+
"#{ redbooth_url }/user?client=client_id&order=created_at_desc"
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
RedboothRuby.request(:post, nil,
|
60
|
-
expect(WebMock).to have_requested(:post, "#{redbooth_url}/user")
|
58
|
+
it 'doesn\'t add a question mark if no params' do
|
59
|
+
RedboothRuby.request(:post, nil, 'user', {}, { session: session })
|
60
|
+
expect(WebMock).to have_requested(:post, "#{ redbooth_url }/user")
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
64
|
-
RedboothRuby.request(:post, nil,
|
65
|
-
expect(WebMock).to have_requested(:post, "#{redbooth_url}/user/new_id")
|
63
|
+
it 'uses the param id to construct the url' do
|
64
|
+
RedboothRuby.request(:post, nil, 'user', { id: 'new_id' }, { session: session })
|
65
|
+
expect(WebMock).to have_requested(:post, "#{ redbooth_url }/user/new_id")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
end
|
69
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'codeclimate-test-reporter'
|
2
2
|
CodeClimate::TestReporter.start
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -24,5 +24,4 @@ end
|
|
24
24
|
|
25
25
|
RSpec.configure do |config|
|
26
26
|
config.include Rack::Test::Methods
|
27
|
-
|
28
|
-
end
|
27
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<html>
|
2
|
+
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
|
3
|
+
<body bgcolor="white">
|
4
|
+
<center><h1>400 Bad Request</h1></center>
|
5
|
+
<center>The plain HTTP request was sent to HTTPS port</center>
|
6
|
+
<hr><center>nginx</center>
|
7
|
+
</body>
|
8
|
+
</html>
|