mavenlink 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/README.md +241 -0
- data/Rakefile +28 -0
- data/bin/mavenlink-console +18 -0
- data/doc/ml_logo_lb-primary.png +0 -0
- data/lib/config/specification.yml +1665 -0
- data/lib/mavenlink.rb +134 -0
- data/lib/mavenlink/account_invitation.rb +4 -0
- data/lib/mavenlink/account_membership.rb +4 -0
- data/lib/mavenlink/additional_item.rb +4 -0
- data/lib/mavenlink/assignment.rb +5 -0
- data/lib/mavenlink/attachment.rb +11 -0
- data/lib/mavenlink/backup_approver_association.rb +4 -0
- data/lib/mavenlink/client.rb +116 -0
- data/lib/mavenlink/concerns/custom_fieldable.rb +9 -0
- data/lib/mavenlink/concerns/indestructible.rb +11 -0
- data/lib/mavenlink/concerns/locked_record.rb +30 -0
- data/lib/mavenlink/cost_rate.rb +4 -0
- data/lib/mavenlink/custom_field.rb +4 -0
- data/lib/mavenlink/custom_field_choice.rb +5 -0
- data/lib/mavenlink/custom_field_value.rb +4 -0
- data/lib/mavenlink/errors.rb +47 -0
- data/lib/mavenlink/expense.rb +4 -0
- data/lib/mavenlink/expense_category.rb +4 -0
- data/lib/mavenlink/expense_report_submission.rb +7 -0
- data/lib/mavenlink/external_payment.rb +4 -0
- data/lib/mavenlink/external_reference.rb +24 -0
- data/lib/mavenlink/fixed_fee_item.rb +4 -0
- data/lib/mavenlink/holiday.rb +4 -0
- data/lib/mavenlink/holiday_calendar.rb +4 -0
- data/lib/mavenlink/holiday_calendar_association.rb +4 -0
- data/lib/mavenlink/holiday_calendar_membership.rb +4 -0
- data/lib/mavenlink/invoice.rb +4 -0
- data/lib/mavenlink/logger.rb +62 -0
- data/lib/mavenlink/model.rb +279 -0
- data/lib/mavenlink/organization.rb +4 -0
- data/lib/mavenlink/organization_membership.rb +4 -0
- data/lib/mavenlink/participation.rb +4 -0
- data/lib/mavenlink/post.rb +4 -0
- data/lib/mavenlink/project_template.rb +4 -0
- data/lib/mavenlink/project_template_assignment.rb +4 -0
- data/lib/mavenlink/railtie.rb +7 -0
- data/lib/mavenlink/rate_card.rb +4 -0
- data/lib/mavenlink/rate_card_role.rb +4 -0
- data/lib/mavenlink/rate_card_set.rb +4 -0
- data/lib/mavenlink/rate_card_set_version.rb +30 -0
- data/lib/mavenlink/rate_card_version.rb +4 -0
- data/lib/mavenlink/request.rb +241 -0
- data/lib/mavenlink/resolution.rb +4 -0
- data/lib/mavenlink/response.rb +22 -0
- data/lib/mavenlink/role.rb +5 -0
- data/lib/mavenlink/settings.rb +11 -0
- data/lib/mavenlink/skill.rb +4 -0
- data/lib/mavenlink/skill_category.rb +4 -0
- data/lib/mavenlink/skill_membership.rb +4 -0
- data/lib/mavenlink/specificators/association.rb +13 -0
- data/lib/mavenlink/specificators/attribute.rb +13 -0
- data/lib/mavenlink/specificators/base.rb +24 -0
- data/lib/mavenlink/specificators/validation.rb +27 -0
- data/lib/mavenlink/status_report.rb +4 -0
- data/lib/mavenlink/story.rb +8 -0
- data/lib/mavenlink/story_allocation_day.rb +5 -0
- data/lib/mavenlink/story_dependency.rb +5 -0
- data/lib/mavenlink/story_task.rb +5 -0
- data/lib/mavenlink/tag.rb +5 -0
- data/lib/mavenlink/time_adjustment.rb +4 -0
- data/lib/mavenlink/time_entry.rb +4 -0
- data/lib/mavenlink/time_off_entry.rb +4 -0
- data/lib/mavenlink/timesheet_submission.rb +4 -0
- data/lib/mavenlink/user.rb +5 -0
- data/lib/mavenlink/vendor.rb +4 -0
- data/lib/mavenlink/workspace.rb +21 -0
- data/lib/mavenlink/workspace_group.rb +5 -0
- data/lib/mavenlink/workspace_invoice_preference.rb +4 -0
- data/lib/mavenlink/workweek.rb +4 -0
- data/lib/mavenlink/workweek_membership.rb +4 -0
- data/mavenlink.gemspec +29 -0
- data/spec/lib/mavenlink/account_membership_spec.rb +8 -0
- data/spec/lib/mavenlink/assignment_spec.rb +17 -0
- data/spec/lib/mavenlink/attachment_spec.rb +30 -0
- data/spec/lib/mavenlink/backup_approver_association_spec.rb +9 -0
- data/spec/lib/mavenlink/client_spec.rb +187 -0
- data/spec/lib/mavenlink/concerns/indestructible_spec.rb +13 -0
- data/spec/lib/mavenlink/concerns/locked_record_spec.rb +28 -0
- data/spec/lib/mavenlink/cost_rate_spec.rb +9 -0
- data/spec/lib/mavenlink/custom_field_value_spec.rb +10 -0
- data/spec/lib/mavenlink/expense_report_submission_spec.rb +16 -0
- data/spec/lib/mavenlink/expense_spec.rb +23 -0
- data/spec/lib/mavenlink/external_references_spec.rb +144 -0
- data/spec/lib/mavenlink/holiday_calendar_association_spec.rb +8 -0
- data/spec/lib/mavenlink/holiday_calendar_membership_spec.rb +8 -0
- data/spec/lib/mavenlink/holiday_spec.rb +7 -0
- data/spec/lib/mavenlink/invalid_request_error_spec.rb +9 -0
- data/spec/lib/mavenlink/invoice_spec.rb +176 -0
- data/spec/lib/mavenlink/model_spec.rb +439 -0
- data/spec/lib/mavenlink/post_spec.rb +23 -0
- data/spec/lib/mavenlink/rate_card_set_version_spec.rb +119 -0
- data/spec/lib/mavenlink/record_invalid_error_spec.rb +16 -0
- data/spec/lib/mavenlink/record_not_found_error_spec.rb +9 -0
- data/spec/lib/mavenlink/request_spec.rb +381 -0
- data/spec/lib/mavenlink/response_spec.rb +50 -0
- data/spec/lib/mavenlink/role_spec.rb +9 -0
- data/spec/lib/mavenlink/settings_spec.rb +23 -0
- data/spec/lib/mavenlink/skill_category_spec.rb +7 -0
- data/spec/lib/mavenlink/skill_membership_spec.rb +9 -0
- data/spec/lib/mavenlink/skill_spec.rb +8 -0
- data/spec/lib/mavenlink/specificators/association_spec.rb +25 -0
- data/spec/lib/mavenlink/specificators/attribute_spec.rb +25 -0
- data/spec/lib/mavenlink/specificators/validation_spec.rb +39 -0
- data/spec/lib/mavenlink/story_allocation_day_spec.rb +64 -0
- data/spec/lib/mavenlink/story_dependency_spec.rb +16 -0
- data/spec/lib/mavenlink/story_spec.rb +69 -0
- data/spec/lib/mavenlink/time_adjustment_spec.rb +13 -0
- data/spec/lib/mavenlink/time_entry_spec.rb +43 -0
- data/spec/lib/mavenlink/time_off_entry_spec.rb +9 -0
- data/spec/lib/mavenlink/user_spec.rb +138 -0
- data/spec/lib/mavenlink/workspace_group_spec.rb +25 -0
- data/spec/lib/mavenlink/workspace_spec.rb +431 -0
- data/spec/lib/mavenlink_spec.rb +43 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/shared_examples.rb +148 -0
- metadata +267 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mavenlink::Post, stub_requests: true do
|
4
|
+
it_should_behave_like 'model', 'posts'
|
5
|
+
|
6
|
+
describe 'validations' do
|
7
|
+
it { should validate_presence_of :message }
|
8
|
+
it { should validate_presence_of :workspace_id }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'associations' do
|
12
|
+
it { should respond_to :subject }
|
13
|
+
it { should respond_to :user }
|
14
|
+
it { should respond_to :workspace }
|
15
|
+
it { should respond_to :story }
|
16
|
+
it { should respond_to :replies }
|
17
|
+
it { should respond_to :newest_reply }
|
18
|
+
it { should respond_to :newest_reply_user }
|
19
|
+
it { should respond_to :recipients }
|
20
|
+
it { should respond_to :google_documents }
|
21
|
+
it { should respond_to :attachments }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Mavenlink::RateCardSetVersion, stub_requests: true do
|
4
|
+
subject { described_class.new(id: "7", rate_card_set_id: "1") }
|
5
|
+
let(:client) { double(Mavenlink::Client) }
|
6
|
+
|
7
|
+
describe "#publish" do
|
8
|
+
context "when the publish is successful" do
|
9
|
+
let(:publish_response) { { "activated" => true } }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(subject).to receive(:persisted?) { true }
|
13
|
+
stub_request :put, "/api/v1/rate_card_set_versions/7/publish", publish_response
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns true" do
|
17
|
+
expect(subject.publish).to eq(true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the publish fails" do
|
22
|
+
before do
|
23
|
+
allow(subject).to receive(:client) { client }
|
24
|
+
allow(client).to receive(:put).and_raise(Faraday::Error)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns false" do
|
28
|
+
expect(subject.publish).to eq(false)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when the record is not persisted" do
|
33
|
+
before do
|
34
|
+
allow(subject).to receive(:persisted?) { false }
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns false" do
|
38
|
+
expect(subject.publish).to eq(false)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#clone" do
|
44
|
+
context "when `clone` is successful" do
|
45
|
+
let(:clone_response) { {
|
46
|
+
"count" => 1,
|
47
|
+
"results" => [
|
48
|
+
{
|
49
|
+
"key" => "rate_card_set_versions",
|
50
|
+
"id" => "8"
|
51
|
+
}
|
52
|
+
],
|
53
|
+
"rate_card_set_versions" => {
|
54
|
+
"8" => {
|
55
|
+
"id" => "8",
|
56
|
+
"effective_date" => "2018-09-04",
|
57
|
+
"rate_card_set_id" => "1"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
} }
|
61
|
+
|
62
|
+
before do
|
63
|
+
stub_request :post, "/api/v1/rate_card_set_versions", clone_response
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns the new rate card set version" do
|
67
|
+
expect_any_instance_of(Mavenlink::Client).to receive(:post).with("rate_card_set_versions",
|
68
|
+
clone_id: subject.id,
|
69
|
+
rate_card_set_version: {
|
70
|
+
rate_card_set_id: subject.rate_card_set_id,
|
71
|
+
effective_date: nil
|
72
|
+
}).and_call_original
|
73
|
+
expect(subject.clone_version).to eq(described_class.new(id: "8", effective_date: "2018-09-04", rate_card_set_id: "1"))
|
74
|
+
end
|
75
|
+
|
76
|
+
it "sends the effective_date parameter" do
|
77
|
+
date = Date.new(2018, 9, 5)
|
78
|
+
expect_any_instance_of(Mavenlink::Client).to receive(:post).with("rate_card_set_versions",
|
79
|
+
clone_id: subject.id,
|
80
|
+
rate_card_set_version: {
|
81
|
+
rate_card_set_id: subject.rate_card_set_id,
|
82
|
+
effective_date: date
|
83
|
+
}).and_call_original
|
84
|
+
subject.clone_version(date)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when `clone` is not successful" do
|
89
|
+
context "when the response is an error" do
|
90
|
+
let(:clone_response) { {
|
91
|
+
"errors" => [
|
92
|
+
{
|
93
|
+
"type" => "system",
|
94
|
+
"message" => "not found"
|
95
|
+
}
|
96
|
+
],
|
97
|
+
} }
|
98
|
+
|
99
|
+
before do
|
100
|
+
stub_request :post, "/api/v1/rate_card_set_versions", clone_response
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns false" do
|
104
|
+
expect(subject.clone_version).to eq(false)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when the record is not persisted" do
|
109
|
+
before do
|
110
|
+
allow(subject).to receive(:persisted?) { false }
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns false" do
|
114
|
+
expect(subject.clone_version).to eq(false)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mavenlink::RecordInvalidError do
|
4
|
+
let(:client) { Object.new }
|
5
|
+
let(:record) { Mavenlink::Workspace.new({ title: nil }, nil, client) }
|
6
|
+
before { record.valid? }
|
7
|
+
|
8
|
+
subject { described_class.new(record) }
|
9
|
+
|
10
|
+
its(:record) { should == record }
|
11
|
+
its(:message) { should == "Title can't be blank" }
|
12
|
+
|
13
|
+
specify do
|
14
|
+
expect { raise subject }.to raise_error described_class, /Title.*blank/
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,381 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mavenlink::Request, stub_requests: true do
|
4
|
+
let(:collection_name) { 'workspaces' }
|
5
|
+
let(:client) { Mavenlink.client }
|
6
|
+
|
7
|
+
subject(:request) { described_class.new(collection_name, client) }
|
8
|
+
|
9
|
+
let(:response) {
|
10
|
+
{
|
11
|
+
'count' => 2,
|
12
|
+
'results' => [{'key' => 'workspaces', 'id' => '7'}, {'key' => 'workspaces', 'id' => '9'}],
|
13
|
+
'workspaces' => {
|
14
|
+
'7' => {'title' => 'My new project'},
|
15
|
+
'9' => {'title' => 'My second project'},
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
let(:one_record_response) {
|
21
|
+
{
|
22
|
+
'count' => 1,
|
23
|
+
'results' => [{'key' => 'workspaces', 'id' => '7'}],
|
24
|
+
'workspaces' => {
|
25
|
+
'7' => {'title' => 'My new project'}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
let(:first_page) {
|
31
|
+
{
|
32
|
+
'count' => 3,
|
33
|
+
'results' => [{'key' => 'workspaces', 'id' => '7'}, {'key' => 'workspaces', 'id' => '9'}],
|
34
|
+
'workspaces' => {
|
35
|
+
'7' => {'title' => 'My new project!'},
|
36
|
+
'9' => {'title' => 'My second project!'},
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
let(:second_page) {
|
42
|
+
{
|
43
|
+
'count' => 3,
|
44
|
+
'results' => [{'key' => 'workspaces', 'id' => '10'}],
|
45
|
+
'workspaces' => {
|
46
|
+
'10' => {'title' => 'My last project!'}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
let(:third_invalid_page) {
|
52
|
+
{
|
53
|
+
'count' => 3,
|
54
|
+
'results' => [{'key' => 'workspaces', 'id' => '11'}],
|
55
|
+
'workspaces' => {
|
56
|
+
'11' => {'title' => 'Not existed project'}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
before do
|
62
|
+
stub_request :get, '/api/v1/workspaces?page=1', first_page
|
63
|
+
stub_request :get, '/api/v1/workspaces?page=2', second_page
|
64
|
+
stub_request :get, '/api/v1/workspaces?page=3', third_invalid_page
|
65
|
+
stub_request :get, '/api/v1/workspaces?only=7', one_record_response
|
66
|
+
stub_request :get, '/api/v1/workspaces?only=8', { 'count' => 0, 'results' => [] }
|
67
|
+
stub_request :put, '/api/v1/workspaces/7', one_record_response
|
68
|
+
stub_request :delete, '/api/v1/workspaces/7', {}
|
69
|
+
stub_request :get, '/api/v1/workspaces', response
|
70
|
+
stub_request :post, '/api/v1/workspaces', one_record_response
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#initialize' do
|
74
|
+
let(:client) { double('client') }
|
75
|
+
|
76
|
+
its(:collection_name) { should == 'workspaces' }
|
77
|
+
its(:client) { should == client }
|
78
|
+
its(:scope) { should == {} }
|
79
|
+
|
80
|
+
context 'no client specified' do
|
81
|
+
subject { described_class.new(collection_name) }
|
82
|
+
its(:client) { should == Mavenlink.client }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#current_page' do
|
87
|
+
specify do
|
88
|
+
expect(request.current_page).to eq(1)
|
89
|
+
end
|
90
|
+
|
91
|
+
specify do
|
92
|
+
expect(request.page(2).current_page).to eq(2)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#chain' do
|
97
|
+
specify do
|
98
|
+
expect(request.chain({})).to be_a described_class
|
99
|
+
end
|
100
|
+
|
101
|
+
specify do
|
102
|
+
expect(request.chain({})).not_to eq(request)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'does not change source scope' do
|
106
|
+
expect { request.chain({changed: true}) }.not_to change { request.scope }
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'merges passed scope' do
|
110
|
+
expect(request.chain(changed: true).scope).to have_key(:changed)
|
111
|
+
expect(request.chain(changed: true).scope).to have_key('changed')
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'assigns the same collection name' do
|
115
|
+
expect(request.chain({}).collection_name).to eq(request.collection_name)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'assigns the same client' do
|
119
|
+
expect(request.chain({}).client).to eq(request.client)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#only' do
|
124
|
+
context 'empty input' do
|
125
|
+
it 'resets the scope' do
|
126
|
+
expect(request.only(1).only([]).scope).not_to have_key(:only)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#without' do
|
132
|
+
it 'removes condition from the scope' do
|
133
|
+
expect(subject.only(1).without(:only).scope).not_to have_key(:only)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#find' do
|
138
|
+
context 'existed record' do
|
139
|
+
it 'returns record wrapped in a model' do
|
140
|
+
expect(request.find(7)).to be_a Mavenlink::Workspace
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'record does not exist' do
|
145
|
+
specify do
|
146
|
+
expect(request.find(8)).to be_nil
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe '#search' do
|
152
|
+
specify do
|
153
|
+
expect(request.search('text').scope).to include(search: 'text')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '#filter' do
|
158
|
+
specify do
|
159
|
+
expect(request.filter(recent: true).scope).to include(recent: true)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#include' do
|
164
|
+
specify do
|
165
|
+
expect(request.include(:users).scope).to include(include: 'users')
|
166
|
+
end
|
167
|
+
|
168
|
+
specify do
|
169
|
+
expect(request.include('users').scope).to include(include: 'users')
|
170
|
+
end
|
171
|
+
|
172
|
+
specify do
|
173
|
+
expect(request.include(%w(users clients)).scope).to include(include: 'users,clients')
|
174
|
+
end
|
175
|
+
|
176
|
+
specify do
|
177
|
+
expect(request.include('users', 'clients').scope).to include(include: 'users,clients')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '#page' do
|
182
|
+
specify do
|
183
|
+
expect(request.page(5).scope).to include(page: 5)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#per_page' do
|
188
|
+
specify do
|
189
|
+
expect(request.per_page(5).scope).to include(per_page: 5)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '#limit' do
|
194
|
+
specify do
|
195
|
+
expect(request.limit(5).scope).to include(limit: 5)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#offset' do
|
200
|
+
specify do
|
201
|
+
expect(request.offset(5).scope).to include(offset: 5)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe '#order' do
|
206
|
+
specify do
|
207
|
+
expect(request.order(:id, :desc).scope).to include(order: 'id:desc')
|
208
|
+
end
|
209
|
+
|
210
|
+
specify do
|
211
|
+
expect(request.order(:id, 'desc').scope).to include(order: 'id:desc')
|
212
|
+
end
|
213
|
+
|
214
|
+
specify do
|
215
|
+
expect(request.order(:id, 'DESC').scope).to include(order: 'id:desc')
|
216
|
+
end
|
217
|
+
|
218
|
+
specify do
|
219
|
+
expect(request.order(:id, true).scope).to include(order: 'id:desc')
|
220
|
+
end
|
221
|
+
|
222
|
+
specify do
|
223
|
+
expect(request.order(:id, false).scope).to include(order: 'id')
|
224
|
+
end
|
225
|
+
|
226
|
+
specify do
|
227
|
+
expect(request.order(:id, 'asc').scope).to include(order: 'id')
|
228
|
+
end
|
229
|
+
|
230
|
+
specify do
|
231
|
+
expect(request.order(:id, 'ASC').scope).to include(order: 'id')
|
232
|
+
end
|
233
|
+
|
234
|
+
specify do
|
235
|
+
expect(request.order(:id, :asc).scope).to include(order: 'id')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe '#build' do
|
240
|
+
it 'returns a model object of the same type as the collection name' do
|
241
|
+
expect(request.build(title: 'New Workspace')).to be_a Mavenlink::Workspace
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe '#create' do
|
246
|
+
specify do
|
247
|
+
expect(request.create({})).to be_a Mavenlink::Response
|
248
|
+
end
|
249
|
+
|
250
|
+
specify do
|
251
|
+
expect(request.create({})).to eq(one_record_response)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe '#update' do
|
256
|
+
specify do
|
257
|
+
expect(request.only(7).update(title: 'New title')).to be_a Mavenlink::Response
|
258
|
+
end
|
259
|
+
|
260
|
+
specify do
|
261
|
+
expect(request.only(7).update(title: 'New title')).to eq(one_record_response)
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'no id specified' do
|
265
|
+
specify do
|
266
|
+
# NOTE(SZ): should we raise InvalidRequestError instead?
|
267
|
+
expect { request.update(title: 'New one') }.to raise_error ArgumentError, /route.*ID/
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe '#delete' do
|
273
|
+
specify do
|
274
|
+
expect(request.only(7).delete).to be_blank
|
275
|
+
end
|
276
|
+
|
277
|
+
context 'no id specified' do
|
278
|
+
specify do
|
279
|
+
# NOTE(SZ): should we raise InvalidRequestError instead?
|
280
|
+
expect { request.delete }.to raise_error ArgumentError, /route.*ID/
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe '#response' do
|
286
|
+
subject { request.response }
|
287
|
+
|
288
|
+
specify do
|
289
|
+
expect(subject).to be_a Mavenlink::Response
|
290
|
+
end
|
291
|
+
|
292
|
+
specify do
|
293
|
+
expect(subject).to eq(response)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
describe '#perform' do
|
298
|
+
specify do
|
299
|
+
expect(request.perform).to be_a Mavenlink::Response
|
300
|
+
end
|
301
|
+
|
302
|
+
specify do
|
303
|
+
expect(request.perform).to eq(response)
|
304
|
+
end
|
305
|
+
|
306
|
+
specify do
|
307
|
+
expect(request.perform { one_record_response }).to be_a Mavenlink::Response
|
308
|
+
end
|
309
|
+
|
310
|
+
specify do
|
311
|
+
expect(request.perform { one_record_response }).to eq(one_record_response)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
describe '#results' do
|
316
|
+
specify do
|
317
|
+
expect(request.results).to have(2).workspaces
|
318
|
+
end
|
319
|
+
|
320
|
+
# NOTE(SZ): missing specs
|
321
|
+
end
|
322
|
+
|
323
|
+
describe '#reload' do
|
324
|
+
specify do
|
325
|
+
expect(request.reload).to have(2).workspaces
|
326
|
+
end
|
327
|
+
|
328
|
+
# NOTE(SZ): missing specs
|
329
|
+
end
|
330
|
+
|
331
|
+
describe '#total_pages' do
|
332
|
+
specify do
|
333
|
+
expect(request.total_pages).to eq(1)
|
334
|
+
end
|
335
|
+
|
336
|
+
# NOTE(SZ): missing specs
|
337
|
+
end
|
338
|
+
|
339
|
+
describe '#limit_value' do
|
340
|
+
specify do
|
341
|
+
expect(request.limit_value).to eq(2)
|
342
|
+
end
|
343
|
+
|
344
|
+
specify do
|
345
|
+
expect(request.limit(5).limit_value).to eq(5)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe '#scoped' do
|
350
|
+
specify do
|
351
|
+
expect(request.scoped).to eq(request)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
describe '#to_hash' do
|
356
|
+
specify do
|
357
|
+
expect(request.to_hash).to eq(request.scope)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
describe '#inspect' do
|
362
|
+
specify do
|
363
|
+
expect(request.inspect).to eq('#<Mavenlink::Request [<Mavenlink::Workspace:>, <Mavenlink::Workspace:>]>')
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe '#each_page' do
|
368
|
+
specify do
|
369
|
+
expect(subject.each_page.to_a).to eq [[{"title"=>"My new project!"}, {"title"=>"My second project!"}],
|
370
|
+
[{"title"=>"My last project!"}]]
|
371
|
+
end
|
372
|
+
|
373
|
+
specify do
|
374
|
+
subject.each_page.to_a.flatten.tap do |records|
|
375
|
+
expect(records[0]).to be_a Mavenlink::Model
|
376
|
+
expect(records[1]).to be_a Mavenlink::Model
|
377
|
+
expect(records[2]).to be_a Mavenlink::Model
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|