action_kit_rest 0.4.0 → 0.4.5
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/.rubocop.yml +26 -0
- data/.ruby-version +1 -1
- data/.travis.yml +7 -1
- data/Gemfile +11 -9
- data/Rakefile +15 -18
- data/action_kit_rest.gemspec +39 -23
- data/lib/action_kit_rest.rb +2 -0
- data/lib/action_kit_rest/action.rb +3 -1
- data/lib/action_kit_rest/actions/event_create_action.rb +5 -3
- data/lib/action_kit_rest/actions/event_signup_action.rb +6 -3
- data/lib/action_kit_rest/actions/unsubscribe_action.rb +3 -1
- data/lib/action_kit_rest/allowed_user_field.rb +10 -0
- data/lib/action_kit_rest/api.rb +9 -7
- data/lib/action_kit_rest/base.rb +5 -4
- data/lib/action_kit_rest/client.rb +5 -3
- data/lib/action_kit_rest/event.rb +3 -1
- data/lib/action_kit_rest/event_signup.rb +3 -1
- data/lib/action_kit_rest/language.rb +3 -1
- data/lib/action_kit_rest/list.rb +3 -1
- data/lib/action_kit_rest/page.rb +4 -2
- data/lib/action_kit_rest/pages/base.rb +4 -5
- data/lib/action_kit_rest/pages/donation_page.rb +3 -1
- data/lib/action_kit_rest/pages/event_campaign_page.rb +4 -2
- data/lib/action_kit_rest/pages/import_page.rb +3 -1
- data/lib/action_kit_rest/pages/signup_page.rb +3 -1
- data/lib/action_kit_rest/pages/unsubscribe_page.rb +3 -1
- data/lib/action_kit_rest/phone.rb +2 -0
- data/lib/action_kit_rest/railties.rb +3 -1
- data/lib/action_kit_rest/response/collection.rb +4 -4
- data/lib/action_kit_rest/response/raise_error.rb +15 -12
- data/lib/action_kit_rest/response/validation_error.rb +7 -0
- data/lib/action_kit_rest/response/wrapper.rb +10 -10
- data/lib/action_kit_rest/tag.rb +6 -6
- data/lib/action_kit_rest/user.rb +3 -1
- data/lib/action_kit_rest/version.rb +3 -1
- data/spec/fixtures/allowed_user_field/get.json +19 -0
- data/spec/lib/action_kit_rest/actions/event_create_action_spec.rb +6 -4
- data/spec/lib/action_kit_rest/actions/event_signup_action_spec.rb +6 -4
- data/spec/lib/action_kit_rest/allowed_user_field_spec.rb +43 -5
- data/spec/lib/action_kit_rest/logger_spec.rb +7 -5
- data/spec/lib/action_kit_rest/page_spec.rb +28 -28
- data/spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb +25 -20
- data/spec/lib/action_kit_rest/pages/import_page_spec.rb +21 -17
- data/spec/lib/action_kit_rest/response/collection_spec.rb +13 -11
- data/spec/lib/action_kit_rest/response/validation_error_spec.rb +29 -0
- data/spec/lib/action_kit_rest/response/wrapper_spec.rb +6 -4
- data/spec/lib/action_kit_rest/user_spec.rb +11 -9
- data/spec/spec_helper.rb +6 -4
- data/spec/support/shared_contexts/stub_logger.rb +4 -2
- metadata +64 -59
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ActionKitRest::Actions::EventSignupAction do
|
4
6
|
describe '#get' do
|
5
|
-
let(:actionkit) { ActionKitRest.new(host: 'test.com')
|
7
|
+
let(:actionkit) { ActionKitRest.new(host: 'test.com') }
|
6
8
|
|
7
9
|
before :each do
|
8
|
-
stub_request(:get,
|
9
|
-
.to_return(body: fixture('action/event_signup_action.json'), status: '200', headers: {content_type:
|
10
|
+
stub_request(:get, 'https://test.com/rest/v1/eventsignupaction/54321/')
|
11
|
+
.to_return(body: fixture('action/event_signup_action.json'), status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
10
12
|
end
|
11
13
|
|
12
14
|
it 'should retrieve eventsignupaction and aggregate parsed event sign-up and user IDs' do
|
13
15
|
ak_event_signup_action = actionkit.event_signup_action.get('54321')
|
14
16
|
|
15
|
-
expect(ak_event_signup_action.id).to eq(
|
17
|
+
expect(ak_event_signup_action.id).to eq(54_321)
|
16
18
|
expect(ak_event_signup_action.event_signup_id).to eq('888')
|
17
19
|
expect(ak_event_signup_action.user_id).to eq('111')
|
18
20
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ActionKitRest::AllowedUserField do
|
4
6
|
let(:status) { 200 }
|
7
|
+
let(:standard_headers) { { content_type: 'application/json; charset=utf-8' } }
|
5
8
|
|
6
9
|
subject { ActionKitRest.new(host: 'test.com', username: 'alice', password: 'somesecret') }
|
7
10
|
|
@@ -11,17 +14,19 @@ describe ActionKitRest::AllowedUserField do
|
|
11
14
|
|
12
15
|
ActionKitRest.stub(:logger).and_return(logger)
|
13
16
|
Vertebrae::Base.stub(:logger).and_return(logger)
|
14
|
-
|
15
|
-
stub_get(request_path).with(basic_auth: ['alice', 'somesecret'])
|
16
|
-
.to_return(body: response_body,
|
17
|
-
status: status,
|
18
|
-
headers: {content_type: "application/json; charset=utf-8"})
|
19
17
|
end
|
20
18
|
|
21
19
|
describe '#list' do
|
22
20
|
let(:request_path) { 'alloweduserfield/' }
|
23
21
|
let(:response_body) { fixture('allowed_user_field/list.json') }
|
24
22
|
|
23
|
+
before :each do
|
24
|
+
stub_get(request_path).with(basic_auth: %w[alice somesecret])
|
25
|
+
.to_return(body: response_body,
|
26
|
+
status: status,
|
27
|
+
headers: standard_headers)
|
28
|
+
end
|
29
|
+
|
25
30
|
it 'should return a list of objects' do
|
26
31
|
fields = subject.allowed_user_field.list
|
27
32
|
fields.each do |field|
|
@@ -34,9 +39,42 @@ describe ActionKitRest::AllowedUserField do
|
|
34
39
|
let(:request_path) { 'alloweduserfield/?name=age' }
|
35
40
|
let(:response_body) { fixture('allowed_user_field/list_filtered.json') }
|
36
41
|
|
42
|
+
before :each do
|
43
|
+
stub_get(request_path).with(basic_auth: %w[alice somesecret])
|
44
|
+
.to_return(body: response_body,
|
45
|
+
status: status,
|
46
|
+
headers: standard_headers)
|
47
|
+
end
|
48
|
+
|
37
49
|
it 'should return a single object' do
|
38
50
|
field = subject.allowed_user_field.find('age')
|
39
51
|
expect(field.field_type).to eq 'integer'
|
40
52
|
end
|
41
53
|
end
|
54
|
+
|
55
|
+
describe '#create' do
|
56
|
+
let(:create_request_path) { 'alloweduserfield/' }
|
57
|
+
let(:create_request_body) { { name: 'foo' }.to_json }
|
58
|
+
let(:create_status) { 201 }
|
59
|
+
let(:created_url) { 'https://test.com/rest/v1/alloweduserfield/foo/' }
|
60
|
+
let(:get_request_path) { 'alloweduserfield/foo/' }
|
61
|
+
let(:get_response_body) { fixture('allowed_user_field/get.json') }
|
62
|
+
|
63
|
+
before :each do
|
64
|
+
stub_post(create_request_path).with(basic_auth: %w[alice somesecret],
|
65
|
+
body: create_request_body)
|
66
|
+
.to_return(status: create_status,
|
67
|
+
headers: standard_headers.merge(Location: created_url))
|
68
|
+
|
69
|
+
stub_get(get_request_path).with(basic_auth: %w[alice somesecret])
|
70
|
+
.to_return(body: get_response_body,
|
71
|
+
status: status,
|
72
|
+
headers: standard_headers)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should POST to the endpoint, then do a GET on the created object' do
|
76
|
+
field = subject.allowed_user_field.create({ name: 'foo' })
|
77
|
+
expect(field.display_name).to eq 'Foo'
|
78
|
+
end
|
79
|
+
end
|
42
80
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ActionKitRest do
|
4
6
|
describe 'logging' do
|
5
|
-
it
|
7
|
+
it 'should have a logger' do
|
6
8
|
ActionKitRest.respond_to?(:logger).should be_truthy
|
7
9
|
end
|
8
10
|
|
9
|
-
it
|
11
|
+
it 'should be able to log debug methods' do
|
10
12
|
ActionKitRest.logger.respond_to?(:debug).should be_truthy
|
11
13
|
end
|
12
14
|
|
13
|
-
it
|
15
|
+
it 'should be settable' do
|
14
16
|
ActionKitRest.respond_to?(:logger=).should be_truthy
|
15
|
-
log = double
|
17
|
+
log = double
|
16
18
|
ActionKitRest.logger = log
|
17
19
|
ActionKitRest.logger.should == log
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
22
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe ActionKitRest::Page do
|
@@ -16,7 +18,7 @@ describe ActionKitRest::Page do
|
|
16
18
|
subject.connection.configuration.host.should == 'test.com'
|
17
19
|
end
|
18
20
|
|
19
|
-
it
|
21
|
+
it 'should have a client' do
|
20
22
|
subject.page.client.should_not be_nil
|
21
23
|
end
|
22
24
|
|
@@ -29,82 +31,80 @@ describe ActionKitRest::Page do
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
describe "retrieval" do
|
34
|
+
describe 'retrieval' do
|
34
35
|
before(:each) do
|
35
|
-
stub_get(request_path).to_return(:
|
36
|
-
:
|
36
|
+
stub_get(request_path).to_return(body: body, status: status,
|
37
|
+
headers: { content_type: 'application/json; charset=utf-8' })
|
37
38
|
end
|
38
39
|
|
39
|
-
describe
|
40
|
+
describe '.list' do
|
40
41
|
let(:status) { 200 }
|
41
42
|
let(:body) { fixture('page/collection.json') }
|
42
43
|
let(:request_path) { 'page/' }
|
43
44
|
|
44
|
-
it
|
45
|
+
it 'should allow listing the objects' do
|
45
46
|
pages = subject.page.list
|
46
47
|
|
47
48
|
pages.should be_an_instance_of(ActionKitRest::Response::Wrapper)
|
48
49
|
|
49
|
-
pages.each do |
|
50
|
+
pages.each do |obj|
|
50
51
|
obj.should be_an_instance_of(Hashie::Mash)
|
51
52
|
obj.should respond_to(:goal)
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
describe
|
57
|
-
|
57
|
+
describe '.page' do
|
58
58
|
let(:body) { fixture('page/object.json') }
|
59
59
|
let(:request_path) { 'page/1/' }
|
60
60
|
|
61
|
-
describe
|
61
|
+
describe 'success' do
|
62
62
|
let(:status) { 200 }
|
63
|
-
it
|
63
|
+
it 'should return a single object' do
|
64
64
|
page = subject.page.get(1)
|
65
65
|
page.goal.should == 10
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe
|
69
|
+
describe 'not found' do
|
70
70
|
let(:status) { 404 }
|
71
71
|
|
72
|
-
it
|
73
|
-
|
72
|
+
it 'should return nil' do
|
73
|
+
-> { subject.page.get(1).should.nil? }.should raise_exception(ActionKitRest::Response::NotFound)
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
77
|
-
describe
|
76
|
+
|
77
|
+
describe 'error' do
|
78
78
|
let(:status) { 400 }
|
79
79
|
let(:body) { fixture('error.json') }
|
80
|
-
|
81
|
-
it
|
82
|
-
|
83
|
-
end
|
80
|
+
|
81
|
+
it 'should raise an ak validation response error' do
|
82
|
+
-> { subject.page.get(1) }.should raise_exception(ActionKitRest::Response::ValidationError)
|
83
|
+
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe 'mailing ID error' do
|
87
87
|
let(:status) { 400 }
|
88
88
|
let(:body) { '{"errors": {"mailing_id": ["Unable to associate this mailing ID with account."]}}' }
|
89
89
|
|
90
|
-
it
|
91
|
-
|
90
|
+
it 'should raise an Invalid AKID response error' do
|
91
|
+
-> { subject.page.get(1) }.should raise_exception(ActionKitRest::Response::InvalidAkidError)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe
|
95
|
+
describe 'an error' do
|
96
96
|
let(:status) { 500 }
|
97
97
|
|
98
|
-
it
|
99
|
-
|
98
|
+
it 'should return nil' do
|
99
|
+
-> { subject.page.get(1).should.nil? }.should raise_exception(StandardError)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe 'try again' do
|
104
104
|
let(:status) { 500 }
|
105
105
|
let(:body) { '{"error": "Sorry, this request could not be processed. Please try again later."}' }
|
106
|
-
it
|
107
|
-
|
106
|
+
it 'should return nil' do
|
107
|
+
-> { subject.page.get(1).should.nil? }.should raise_exception(ActionKitRest::Response::TryAgainLater)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -1,34 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/shared_contexts/stub_logger'
|
3
5
|
|
4
6
|
describe ActionKitRest::Pages::EventCampaignPage do
|
5
|
-
include_context
|
7
|
+
include_context 'stub_logger'
|
6
8
|
|
7
9
|
describe 'create' do
|
8
|
-
let(:actionkit) { ActionKitRest.new(host: 'test.com')
|
10
|
+
let(:actionkit) { ActionKitRest.new(host: 'test.com') }
|
9
11
|
|
10
|
-
let(:event_campaign_title) {
|
11
|
-
let(:event_campaign_name) {
|
12
|
+
let(:event_campaign_title) { 'Climate Change Paris 2015' }
|
13
|
+
let(:event_campaign_name) { 'climate-change-paris-2015' }
|
12
14
|
|
13
15
|
before :each do
|
14
16
|
stub_request(:post, 'https://test.com/rest/v1/campaign/')
|
15
17
|
.with(body: "{\"title\":\"#{event_campaign_title}\",\"name\":\"#{event_campaign_name}\"}")
|
16
|
-
.to_return({status: '200', headers: {location: 'https://test.com/rest/v1/campaign/88/'} })
|
18
|
+
.to_return({ status: '200', headers: { location: 'https://test.com/rest/v1/campaign/88/' } })
|
17
19
|
|
18
20
|
stub_request(:get, 'https://test.com/rest/v1/campaign/88/')
|
19
|
-
.to_return({body: fixture('page/campaign.json'), status: '200',
|
21
|
+
.to_return({ body: fixture('page/campaign.json'), status: '200',
|
22
|
+
headers: { content_type: 'application/json; charset=utf-8' } })
|
20
23
|
|
21
24
|
stub_request(:post, 'https://test.com/rest/v1/eventcreatepage/')
|
22
|
-
.with(:
|
23
|
-
.to_return({status: '200', headers: {location:
|
25
|
+
.with(body: '{"campaign":"/rest/v1/campaign/88/","name":"climate-change-paris-2015-event-create","title":"Climate Change Paris 2015: event create","tags":["/rest/v1/tag/1/","/rest/v1/tag/5/"]}')
|
26
|
+
.to_return({ status: '200', headers: { location: 'https://test.com/rest/v1/eventcreatepage/99/' } })
|
24
27
|
|
25
28
|
stub_request(:post, 'https://test.com/rest/v1/eventsignuppage/')
|
26
|
-
.with(:
|
27
|
-
.to_return({status: '200', headers: {location:
|
29
|
+
.with(body: '{"campaign":"/rest/v1/campaign/88/","name":"climate-change-paris-2015-event-signup","title":"Climate Change Paris 2015: event signup","tags":["/rest/v1/tag/1/","/rest/v1/tag/5/"]}')
|
30
|
+
.to_return({ status: '200', headers: { location: 'https://test.com/rest/v1/eventsignuppage/111/' } })
|
28
31
|
end
|
29
32
|
|
30
33
|
it 'should create an event campaign' do
|
31
|
-
resp = actionkit.event_campaign_page.create({title: 'Climate Change Paris 2015',
|
34
|
+
resp = actionkit.event_campaign_page.create({ title: 'Climate Change Paris 2015',
|
35
|
+
name: 'climate-change-paris-2015', event_pages_tags: ['/rest/v1/tag/1/', '/rest/v1/tag/5/'] })
|
32
36
|
expect(resp.title).to eq event_campaign_title
|
33
37
|
expect(resp.name).to eq event_campaign_name
|
34
38
|
|
@@ -37,7 +41,8 @@ describe ActionKitRest::Pages::EventCampaignPage do
|
|
37
41
|
end
|
38
42
|
|
39
43
|
it 'should create associated event and signup create pages' do
|
40
|
-
resp = actionkit.event_campaign_page.create({title: 'Climate Change Paris 2015',
|
44
|
+
resp = actionkit.event_campaign_page.create({ title: 'Climate Change Paris 2015',
|
45
|
+
name: 'climate-change-paris-2015', event_pages_tags: ['/rest/v1/tag/1/', '/rest/v1/tag/5/'] })
|
41
46
|
expect(resp.event_create_page_name).to eq 'climate-change-paris-2015-event-create'
|
42
47
|
expect(resp.event_signup_page_name).to eq 'climate-change-paris-2015-event-signup'
|
43
48
|
|
@@ -47,18 +52,18 @@ describe ActionKitRest::Pages::EventCampaignPage do
|
|
47
52
|
end
|
48
53
|
|
49
54
|
describe 'find' do
|
50
|
-
let(:actionkit) { ActionKitRest.new(host: 'test.com')
|
55
|
+
let(:actionkit) { ActionKitRest.new(host: 'test.com') }
|
51
56
|
|
52
|
-
let(:event_campaign_title) {
|
53
|
-
let(:event_campaign_name) {
|
57
|
+
let(:event_campaign_title) { 'Climate Change Paris 2015' }
|
58
|
+
let(:event_campaign_name) { 'climate-change-paris-2015' }
|
54
59
|
|
55
60
|
before :each do
|
56
61
|
stub_request(:get, 'https://test.com/rest/v1/campaign/?name=climate-change-paris-2015')
|
57
|
-
.to_return(body: fixture('page/find_campaign.json'), status: '200', headers: {content_type:
|
58
|
-
stub_request(:get,
|
59
|
-
.to_return(body: fixture('page/find_event_create.json'), status: '200', headers: {content_type:
|
60
|
-
stub_request(:get,
|
61
|
-
.to_return(body: fixture('page/find_event_signup.json'), status: '200', headers: {content_type:
|
62
|
+
.to_return(body: fixture('page/find_campaign.json'), status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
63
|
+
stub_request(:get, 'https://test.com/rest/v1/eventcreatepage/?name=climate-change-paris-2015-event-create')
|
64
|
+
.to_return(body: fixture('page/find_event_create.json'), status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
65
|
+
stub_request(:get, 'https://test.com/rest/v1/eventsignuppage/?name=climate-change-paris-2015-event-signup')
|
66
|
+
.to_return(body: fixture('page/find_event_signup.json'), status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
62
67
|
end
|
63
68
|
|
64
69
|
it 'should retrieve event campaign by name' do
|
@@ -1,27 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'support/shared_contexts/stub_logger'
|
3
5
|
|
4
6
|
describe ActionKitRest::Pages::ImportPage do
|
5
|
-
include_context
|
7
|
+
include_context 'stub_logger'
|
6
8
|
|
7
|
-
let(:actionkit) { ActionKitRest.new(host: 'test.com')
|
9
|
+
let(:actionkit) { ActionKitRest.new(host: 'test.com') }
|
8
10
|
let(:status) { 200 }
|
9
11
|
|
10
|
-
describe
|
11
|
-
let(:body) {
|
12
|
-
let(:request_body) { {title:
|
12
|
+
describe 'create' do
|
13
|
+
let(:body) { '' }
|
14
|
+
let(:request_body) { { title: 'Title', name: 'name' }.to_json }
|
13
15
|
let(:request_path) { 'importpage/' }
|
14
16
|
|
15
17
|
before(:each) do
|
16
|
-
stub_post(request_path).with(body: request_body).to_return(:
|
17
|
-
:
|
18
|
+
stub_post(request_path).with(body: request_body).to_return(body: body, status: status,
|
19
|
+
headers: { location: 'https://test.com/rest/v1/importpage/1093/', content_type: 'application/json; charset=utf-8' })
|
18
20
|
|
19
|
-
stub_request(:get,
|
21
|
+
stub_request(:get, 'https://test.com/rest/v1/importpage/1093/').to_return(body: fixture('page/object.json'),
|
22
|
+
status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
20
23
|
end
|
21
24
|
|
22
|
-
describe
|
23
|
-
it
|
24
|
-
resp = actionkit.import_page.create(title:
|
25
|
+
describe '.create' do
|
26
|
+
it 'should allow creation' do
|
27
|
+
resp = actionkit.import_page.create(title: 'Title', name: 'name')
|
25
28
|
expect(resp.title).to eq 'Demand a Sustainable USDA'
|
26
29
|
end
|
27
30
|
end
|
@@ -29,21 +32,22 @@ describe ActionKitRest::Pages::ImportPage do
|
|
29
32
|
|
30
33
|
describe 'update' do
|
31
34
|
let(:body) { '' }
|
32
|
-
let(:request_body) { {title:
|
35
|
+
let(:request_body) { { title: 'Title', name: 'name' }.to_json }
|
33
36
|
let(:request_path) { 'importpage/1093/' }
|
34
37
|
|
35
38
|
before(:each) do
|
36
|
-
stub_put(request_path).with(body: request_body).to_return(:
|
37
|
-
|
39
|
+
stub_put(request_path).with(body: request_body).to_return(body: body, status: status,
|
40
|
+
headers: { content_type: 'application/json; charset=utf-8' })
|
38
41
|
|
39
|
-
stub_request(:get,
|
42
|
+
stub_request(:get, 'https://test.com/rest/v1/importpage/1093/').to_return(body: fixture('page/object.json'),
|
43
|
+
status: '200', headers: { content_type: 'application/json; charset=utf-8' })
|
40
44
|
end
|
41
45
|
|
42
46
|
describe '.update' do
|
43
47
|
it 'should allow updates' do
|
44
|
-
resp = actionkit.import_page.update('1093', title:
|
48
|
+
resp = actionkit.import_page.update('1093', title: 'Title', name: 'name')
|
45
49
|
expect(resp.title).to eq 'Demand a Sustainable USDA'
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
49
|
-
end
|
53
|
+
end
|
@@ -1,26 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe ActionKitRest::Response::Collection
|
4
|
-
let(:meta) { double
|
5
|
-
let(:objects) { double
|
5
|
+
describe ActionKitRest::Response::Collection do
|
6
|
+
let(:meta) { double }
|
7
|
+
let(:objects) { double }
|
6
8
|
subject { ActionKitRest::Response::Collection.new(meta, objects) }
|
7
9
|
|
8
10
|
describe 'initialization' do
|
9
11
|
it 'should set meta and objects' do
|
10
|
-
subject.meta.
|
11
|
-
subject.objects.
|
12
|
+
expect(subject.meta).to eq(meta)
|
13
|
+
expect(subject.objects).to eq(objects)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
17
|
describe 'each' do
|
16
18
|
let(:item1) { double }
|
17
19
|
let(:item2) { double }
|
18
|
-
let(:objects) { [
|
20
|
+
let(:objects) { [item1, item2] }
|
19
21
|
|
20
|
-
it
|
21
|
-
subject.count.
|
22
|
-
subject.any? { |i| i == item1 }
|
23
|
-
subject.any? { |i| i == item2 }
|
22
|
+
it 'should return all collection items' do
|
23
|
+
expect(subject.count).to eq(2)
|
24
|
+
expect(subject.any? { |i| i == item1 }).to be_truthy
|
25
|
+
expect(subject.any? { |i| i == item2 }).to be_truthy
|
24
26
|
end
|
25
27
|
end
|
26
|
-
end
|
28
|
+
end
|