the-city-admin 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/.pryrc +3 -0
- data/.rspec +1 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +58 -28
- data/README.rdoc +4 -1
- data/examples/barcodes_checkins.rb +37 -14
- data/lib/api/checkin.rb +1 -1
- data/lib/api/checkin_list.rb +0 -1
- data/lib/api/checkin_list_by_callboard_number.rb +61 -0
- data/lib/api/checkin_list_by_pager_number.rb +61 -0
- data/lib/api/group_checkin.rb +13 -2
- data/lib/api/group_checkin_event.rb +24 -0
- data/lib/api/group_checkin_events_list.rb +64 -0
- data/lib/api/group_checkin_list.rb +2 -2
- data/lib/readers/api_reader.rb +9 -2
- data/lib/readers/checkin_list_by_callboard_number_reader.rb +27 -0
- data/lib/readers/checkin_list_by_pager_number_reader.rb +27 -0
- data/lib/readers/checkin_list_reader.rb +2 -2
- data/lib/readers/group_checkin_events_list_reader.rb +28 -0
- data/lib/readers/group_checkin_reader.rb +32 -0
- data/lib/readers/group_list_reader.rb +0 -1
- data/spec/api/checkin_list_by_callboard_number_spec.rb +91 -0
- data/spec/api/checkin_list_by_pager_number_spec.rb +98 -0
- data/spec/api/checkin_list_spec.rb +91 -0
- data/spec/api/group_address_list_spec.rb +1 -1
- data/spec/api/group_address_spec.rb +2 -3
- data/spec/api/group_checkin_events_list_spec.rb +91 -0
- data/spec/api/group_checkin_list_spec.rb +1 -1
- data/spec/api/group_checkin_spec.rb +12 -0
- data/spec/api/group_event_attendance_list_spec.rb +1 -1
- data/spec/api/group_export_spec.rb +1 -5
- data/spec/api/group_invitation_list_spec.rb +6 -6
- data/spec/api/group_invitation_spec.rb +1 -5
- data/spec/api/group_list_spec.rb +72 -7
- data/spec/api/group_role_list_spec.rb +6 -6
- data/spec/api/group_role_spec.rb +1 -5
- data/spec/api/group_spec.rb +1 -5
- data/spec/api/group_tag_list_spec.rb +6 -6
- data/spec/api/group_tag_spec.rb +1 -5
- data/spec/api/metric_list_spec.rb +6 -6
- data/spec/api/metric_measurement_list_spec.rb +6 -6
- data/spec/api/metric_measurement_spec.rb +2 -2
- data/spec/api/metric_spec.rb +2 -2
- data/spec/api/role_list_spec.rb +1 -1
- data/spec/api/role_spec.rb +2 -2
- data/spec/api/skill_list_spec.rb +1 -1
- data/spec/api/skilled_user_id_list_spec.rb +1 -1
- data/spec/api/skilled_user_list_spec.rb +1 -1
- data/spec/api/tag_group_list_spec.rb +1 -1
- data/spec/api/tag_list_spec.rb +1 -1
- data/spec/api/tag_spec.rb +2 -2
- data/spec/api/terminology_list_spec.rb +1 -1
- data/spec/api/terminology_spec.rb +2 -2
- data/spec/api/user_address_list_spec.rb +1 -1
- data/spec/api/user_address_spec.rb +2 -2
- data/spec/api/user_admin_privilege_list_spec.rb +1 -1
- data/spec/api/user_admin_privilege_spec.rb +2 -2
- data/spec/api/user_barcode_spec.rb +2 -2
- data/spec/api/user_family_list_spec.rb +1 -1
- data/spec/api/user_family_member_spec.rb +2 -2
- data/spec/api/user_invitation_list_spec.rb +1 -1
- data/spec/api/user_invitation_spec.rb +2 -2
- data/spec/api/user_list_spec.rb +1 -1
- data/spec/api/user_note_list_spec.rb +1 -1
- data/spec/api/user_note_spec.rb +2 -2
- data/spec/api/user_process_answer_list_spec.rb +1 -1
- data/spec/api/user_process_list_spec.rb +1 -1
- data/spec/api/user_process_spec.rb +2 -2
- data/spec/api/user_role_list_spec.rb +1 -1
- data/spec/api/user_role_spec.rb +2 -2
- data/spec/api/user_skill_list_spec.rb +1 -1
- data/spec/api/user_skill_spec.rb +2 -2
- data/spec/api/user_spec.rb +1 -2
- data/spec/api/web_hook_list_spec.rb +1 -1
- data/spec/api/web_hook_spec.rb +2 -2
- data/spec/factories/group_checkin_event.rb +20 -0
- data/spec/factories/group_checkin_events_list.rb +14 -0
- data/spec/factories/group_list.rb +13 -0
- data/spec/functional/the_city_admin_spec.rb +5 -5
- data/spec/readers/api_reader_spec.rb +3 -5
- data/spec/readers/user_reader_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -7
- data/thecity_admin_api.gemspec +6 -5
- metadata +51 -8
- data/.autotest +0 -9
- data/.rvmrc +0 -1
@@ -0,0 +1,64 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class GroupCheckinEventsList < ApiList
|
4
|
+
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
# Constructor.
|
8
|
+
#
|
9
|
+
# @param options A hash of options for loading the list.
|
10
|
+
#
|
11
|
+
# Options:
|
12
|
+
# :group_id - The ID of the group to load the checkin events for. (required)
|
13
|
+
# :page - The page number to get.
|
14
|
+
# :target_date - Date to pull checkin events for. Defaults to nearest checkin date
|
15
|
+
# :reader - The Reader to use to load the data.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# Examples:
|
19
|
+
# GroupCheckinEventsList.new({:group_id => 12345})
|
20
|
+
#
|
21
|
+
# GroupCheckinEventsList.new({:group_id => 12345, :page => 2})
|
22
|
+
#
|
23
|
+
def initialize(options = {})
|
24
|
+
@options = options
|
25
|
+
@options[:reader] = TheCity::GroupCheckinEventsListReader.new(@options) if @options[:reader].nil?
|
26
|
+
@json_data = @options[:reader].load_feed
|
27
|
+
|
28
|
+
@total_entries = @json_data['total_entries']
|
29
|
+
@total_pages = @json_data['total_pages']
|
30
|
+
@per_page = @json_data['per_page']
|
31
|
+
@current_page = @json_data['current_page']
|
32
|
+
@target_date = @json_data['target_date']
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Get the specified note.
|
37
|
+
#
|
38
|
+
# @param index The index of the checkin event to get.
|
39
|
+
#
|
40
|
+
# @return [GroupCheckinEvent]
|
41
|
+
def [](index)
|
42
|
+
GroupCheckinEvent.new( @json_data['checkin_events'][index] ) if @json_data['checkin_events'][index]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# This method is needed for Enumerable.
|
47
|
+
def each &block
|
48
|
+
@json_data['checkin_events'].each{ |checkin| yield( GroupCheckinEvent.new(checkin) )}
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Alias the count method
|
53
|
+
alias :size :count
|
54
|
+
|
55
|
+
# Checks if the list is empty.
|
56
|
+
#
|
57
|
+
# @return True on empty, false otherwise.
|
58
|
+
def empty?
|
59
|
+
@json_data['checkin_events'].empty?
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -9,7 +9,7 @@ module TheCity
|
|
9
9
|
# @param options A hash of options for loading the list.
|
10
10
|
#
|
11
11
|
# Options:
|
12
|
-
# :group_id - The ID of the group to load the
|
12
|
+
# :group_id - The ID of the group to load the checkins for. (required)
|
13
13
|
# :page - The page number to get.
|
14
14
|
# :reader - The Reader to use to load the data.
|
15
15
|
#
|
@@ -33,7 +33,7 @@ module TheCity
|
|
33
33
|
|
34
34
|
# Get the specified note.
|
35
35
|
#
|
36
|
-
# @param index The index of the
|
36
|
+
# @param index The index of the checkin to get.
|
37
37
|
#
|
38
38
|
# @return [GroupCheckin]
|
39
39
|
def [](index)
|
data/lib/readers/api_reader.rb
CHANGED
@@ -16,6 +16,7 @@ module TheCity
|
|
16
16
|
# data = @cacher.get_data( @class_key )
|
17
17
|
# else
|
18
18
|
@url_data_params ||= {}
|
19
|
+
@url_data_params = stringify_array_params(@url_data_params)
|
19
20
|
response = TheCity::admin_request(:get, @url_data_path, @url_data_params)
|
20
21
|
data = JSON.parse(response.body)
|
21
22
|
@headers = response.headers
|
@@ -29,7 +30,7 @@ module TheCity
|
|
29
30
|
# x-city-ratelimit-limit-by-account header, whichever is lower.
|
30
31
|
def rate_limit
|
31
32
|
if @headers
|
32
|
-
[@headers['
|
33
|
+
[@headers['X-City-RateLimit-Limit-By-Ip'].to_i, @headers['X-City-RateLimit-Limit-By-Account'].to_i].min
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -37,10 +38,16 @@ module TheCity
|
|
37
38
|
# x-city-ratelimit-remaining-by-account header, whichever is lower.
|
38
39
|
def rate_limit_remaining
|
39
40
|
if @headers
|
40
|
-
[@headers['
|
41
|
+
[@headers['X-City-RateLimit-Remaining-By-Ip'].to_i, @headers['X-City-RateLimit-Remaining-By-Account'].to_i].min
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
private
|
46
|
+
|
47
|
+
def stringify_array_params(options)
|
48
|
+
options.each_key {|k| options[k] = "#{options[k]}" if options[k].is_a? Array}
|
49
|
+
end
|
50
|
+
|
44
51
|
end
|
45
52
|
|
46
53
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class CheckinListByCallboardNumberReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param callboard_number The callboard number to filter by
|
8
|
+
# @param options A hash of options for requesting data from the server.
|
9
|
+
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
|
+
def initialize(callboard_number, options = {}, cacher = nil)
|
11
|
+
options[:page] ||= 1
|
12
|
+
#@class_key = "checkin_list_#{page}"
|
13
|
+
@url_data_path = "/checkins/by_callboard_number/#{URI.escape(callboard_number)}"
|
14
|
+
@url_data_params = white_list_options(options)
|
15
|
+
|
16
|
+
# The object to store and load the cache.
|
17
|
+
@cacher = cacher unless cacher.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def white_list_options(options)
|
21
|
+
white_list = [:page, :include_checked_out, :under_checkin_group_id]
|
22
|
+
options.clone.delete_if { |key, value| !white_list.include?(key) }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class CheckinListByPagerNumberReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param pager_number The pager number to filter by
|
8
|
+
# @param options A hash of options for requesting data from the server.
|
9
|
+
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
|
+
def initialize(pager_number, options = {}, cacher = nil)
|
11
|
+
options[:page] ||= 1
|
12
|
+
#@class_key = "checkin_list_#{page}"
|
13
|
+
@url_data_path = "/checkins/by_pager_number/#{URI.escape(pager_number)}"
|
14
|
+
@url_data_params = white_list_options(options)
|
15
|
+
|
16
|
+
# The object to store and load the cache.
|
17
|
+
@cacher = cacher unless cacher.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def white_list_options(options)
|
21
|
+
white_list = [:page, :include_checked_out, :under_checkin_group_id]
|
22
|
+
options.clone.delete_if { |key, value| !white_list.include?(key) }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -6,9 +6,9 @@ module TheCity
|
|
6
6
|
#
|
7
7
|
# @param options A hash of options for requesting data from the server.
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
|
-
def initialize(options = {}, cacher = nil)
|
9
|
+
def initialize(options = {}, cacher = nil)
|
10
10
|
options[:page] ||= 1
|
11
|
-
#@class_key = "checkin_list_#{page}"
|
11
|
+
#@class_key = "checkin_list_#{page}"
|
12
12
|
@url_data_path = "/checkins"
|
13
13
|
@url_data_params = white_list_options(options)
|
14
14
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class GroupCheckinEventsListReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param options A hash of options for requesting data from the server.
|
8
|
+
# :: group_id is required
|
9
|
+
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
|
+
def initialize(options = {}, cacher = nil)
|
11
|
+
options[:page] ||= 1
|
12
|
+
group_id = options.delete(:group_id)
|
13
|
+
#@class_key = "groups_#{group_id}_checkin_events"
|
14
|
+
@url_data_path = "/groups/#{group_id}/checkin_events"
|
15
|
+
@url_data_params = white_list_options(options)
|
16
|
+
|
17
|
+
# The object to store and load the cache.
|
18
|
+
@cacher = cacher unless cacher.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def white_list_options(options)
|
22
|
+
white_list = [:page, :target_date]
|
23
|
+
options.clone.delete_if { |key, value| !white_list.include?(key) }
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class GroupCheckinReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param group_id The ID of the group to load.
|
8
|
+
# @param checkin_id The ID of the group_checkin to load.
|
9
|
+
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
|
+
def initialize(group_id, checkin_id, by_id='id', cacher = nil)
|
11
|
+
#@class_key = "groups_#{group_id}_checkins_#{checkin_id}"
|
12
|
+
@url_data_path = case by_id
|
13
|
+
when 'id'
|
14
|
+
"/groups/#{group_id}/checkins/#{checkin_id}"
|
15
|
+
when 'pager_number'
|
16
|
+
"/groups/#{group_id}/checkins/by_pager_number?pager_number=#{URI.escape(checkin_id)}"
|
17
|
+
when 'callboard_number'
|
18
|
+
"/groups/#{group_id}/checkins/by_callboard_number?callboard_number=#{URI.escape(checkin_id)}"
|
19
|
+
else
|
20
|
+
"/groups/#{group_id}/checkins/#{checkin_id}"
|
21
|
+
end
|
22
|
+
#@url_data_params = options
|
23
|
+
|
24
|
+
# The object to store and load the cache.
|
25
|
+
@cacher = cacher unless cacher.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -12,7 +12,6 @@ module TheCity
|
|
12
12
|
#@class_key = "group_list_#{options[:page]}_{some_kind_of_md5_thing_here}"
|
13
13
|
@url_data_path = "/groups"
|
14
14
|
@url_data_params = white_list_options(options)
|
15
|
-
|
16
15
|
# The object to store and load the cache.
|
17
16
|
@cacher = cacher unless cacher.nil?
|
18
17
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe 'CheckinListByCallboardNumber' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
#simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should pass if group checkin list attribute is not specified' do
|
14
|
+
group_id = 123
|
15
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
16
|
+
:total_entries => 1,
|
17
|
+
:total_pages => 1,
|
18
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
19
|
+
}).to_json
|
20
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
21
|
+
checkin_list = TheCity::CheckinListByCallboardNumber.new('12345')
|
22
|
+
checkin = checkin_list[0]
|
23
|
+
checkin.parent_group_name.should == "Ballard Childrens ministry"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
it 'should pass if group checkin list is empty' do
|
28
|
+
group_id = 123
|
29
|
+
page = 2
|
30
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
31
|
+
:total_entries => 1,
|
32
|
+
:total_pages => 1,
|
33
|
+
:checkins => []
|
34
|
+
}).to_json
|
35
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
36
|
+
checkin_list = TheCity::CheckinListByCallboardNumber.new('12345')
|
37
|
+
|
38
|
+
checkin_list.empty?.should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
it 'should return a valid list of group checkins' do
|
43
|
+
group_id = 123
|
44
|
+
page = 2
|
45
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
46
|
+
:total_entries => 1,
|
47
|
+
:total_pages => 1,
|
48
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
49
|
+
}).to_json
|
50
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
51
|
+
checkin_list = TheCity::CheckinListByCallboardNumber.new('12345')
|
52
|
+
|
53
|
+
checkin = checkin_list[0]
|
54
|
+
checkin.parent_group_name.should == "Ballard Childrens ministry"
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
it 'should iterate using *each* method' do
|
59
|
+
group_id = 123
|
60
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
61
|
+
:total_entries => 1,
|
62
|
+
:total_pages => 1,
|
63
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
64
|
+
}).to_json
|
65
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
66
|
+
checkin_list = TheCity::CheckinListByCallboardNumber.new('12345')
|
67
|
+
|
68
|
+
checkins = []
|
69
|
+
checkin_list.each { |checkin| checkins << checkin.parent_group_name }
|
70
|
+
checkins.should == ["Ballard Childrens ministry"]
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
it 'should iterate using *collect* method' do
|
75
|
+
group_id = 123
|
76
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
77
|
+
:total_entries => 1,
|
78
|
+
:total_pages => 1,
|
79
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
80
|
+
}).to_json
|
81
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
82
|
+
checkin_list = TheCity::CheckinListByCallboardNumber.new('12345')
|
83
|
+
|
84
|
+
checkins = checkin_list.collect { |checkin| checkin.parent_group_name }
|
85
|
+
checkins.should == ["Ballard Childrens ministry"]
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe 'CheckinListByPagerNumber' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
#simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
# it 'really gets a group checkin list by pager number' do
|
14
|
+
# TheCity::AdminApi.connect('af504c86420116f135b886a83667b0246784ce41', '96f6257ac4bd57f4')
|
15
|
+
# checkin_list = TheCity::CheckinListByPagerNumber.new('111', {:include_checked_out => true, :under_checkin_group_id => 49861013})
|
16
|
+
# binding.pry
|
17
|
+
# checkin_list.should_not be_nil
|
18
|
+
# end
|
19
|
+
|
20
|
+
it 'should pass if group checkin list attribute is not specified' do
|
21
|
+
group_id = 123
|
22
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
23
|
+
:total_entries => 1,
|
24
|
+
:total_pages => 1,
|
25
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
26
|
+
}).to_json
|
27
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
28
|
+
checkin_list = TheCity::CheckinListByPagerNumber.new('111')
|
29
|
+
checkin = checkin_list[0]
|
30
|
+
checkin.parent_group_name.should == "Ballard Childrens ministry"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
it 'should pass if group checkin list is empty' do
|
35
|
+
group_id = 123
|
36
|
+
page = 2
|
37
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
38
|
+
:total_entries => 1,
|
39
|
+
:total_pages => 1,
|
40
|
+
:checkins => []
|
41
|
+
}).to_json
|
42
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
43
|
+
checkin_list = TheCity::CheckinListByPagerNumber.new('111')
|
44
|
+
|
45
|
+
checkin_list.empty?.should be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
it 'should return a valid list of group checkins' do
|
50
|
+
group_id = 123
|
51
|
+
page = 2
|
52
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
53
|
+
:total_entries => 1,
|
54
|
+
:total_pages => 1,
|
55
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
56
|
+
}).to_json
|
57
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
58
|
+
checkin_list = TheCity::CheckinListByPagerNumber.new('111')
|
59
|
+
|
60
|
+
checkin = checkin_list[0]
|
61
|
+
checkin.parent_group_name.should == "Ballard Childrens ministry"
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
it 'should iterate using *each* method' do
|
66
|
+
group_id = 123
|
67
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
68
|
+
:total_entries => 1,
|
69
|
+
:total_pages => 1,
|
70
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
71
|
+
}).to_json
|
72
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
73
|
+
checkin_list = TheCity::CheckinListByPagerNumber.new('111')
|
74
|
+
|
75
|
+
checkins = []
|
76
|
+
checkin_list.each { |checkin| checkins << checkin.parent_group_name }
|
77
|
+
checkins.should == ["Ballard Childrens ministry"]
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
it 'should iterate using *collect* method' do
|
82
|
+
group_id = 123
|
83
|
+
request_data = FactoryGirl.attributes_for(:checkin_list, {
|
84
|
+
:total_entries => 1,
|
85
|
+
:total_pages => 1,
|
86
|
+
:checkins => [FactoryGirl.attributes_for(:group_checkin)]
|
87
|
+
}).to_json
|
88
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
89
|
+
checkin_list = TheCity::CheckinListByPagerNumber.new('111')
|
90
|
+
|
91
|
+
checkins = checkin_list.collect { |checkin| checkin.parent_group_name }
|
92
|
+
checkins.should == ["Ballard Childrens ministry"]
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|