the-city-admin 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +9 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.yardoc/checksums +50 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +51 -0
- data/README +1 -0
- data/Rakefile +32 -0
- data/index.rb +123 -0
- data/lib/common.rb +163 -72
- data/lib/the_city_admin.rb +2 -2
- data/notes.txt +21 -0
- data/spec/api/address_list_spec.rb +0 -0
- data/spec/api/address_spec.rb +0 -0
- data/spec/api/group_address_list_spec.rb +93 -0
- data/spec/api/group_address_spec.rb +19 -0
- data/spec/api/group_checkin_list_spec.rb +93 -0
- data/spec/api/group_event_attendance_list_spec.rb +93 -0
- data/spec/api/group_export_spec.rb +19 -0
- data/spec/api/group_invitation_list_spec.rb +23 -0
- data/spec/api/group_invitation_spec.rb +19 -0
- data/spec/api/group_list_spec.rb +23 -0
- data/spec/api/group_role_list_spec.rb +23 -0
- data/spec/api/group_role_spec.rb +19 -0
- data/spec/api/group_spec.rb +19 -0
- data/spec/api/group_tag_list_spec.rb +23 -0
- data/spec/api/group_tag_spec.rb +19 -0
- data/spec/api/metric_list_spec.rb +22 -0
- data/spec/api/metric_measurement_list_spec.rb +23 -0
- data/spec/api/metric_measurement_spec.rb +19 -0
- data/spec/api/metric_spec.rb +19 -0
- data/spec/api/role_list_spec.rb +75 -0
- data/spec/api/role_spec.rb +19 -0
- data/spec/api/skill_list_spec.rb +76 -0
- data/spec/api/skilled_user_id_list_spec.rb +82 -0
- data/spec/api/skilled_user_list_spec.rb +82 -0
- data/spec/api/tag_group_list_spec.rb +72 -0
- data/spec/api/tag_list_spec.rb +77 -0
- data/spec/api/tag_spec.rb +19 -0
- data/spec/api/terminology_list_spec.rb +75 -0
- data/spec/api/terminology_spec.rb +19 -0
- data/spec/api/user_address_list_spec.rb +92 -0
- data/spec/api/user_address_spec.rb +19 -0
- data/spec/api/user_admin_privilege_list_spec.rb +94 -0
- data/spec/api/user_admin_privilege_spec.rb +19 -0
- data/spec/api/user_barcode_spec.rb +19 -0
- data/spec/api/user_family_list_spec.rb +91 -0
- data/spec/api/user_family_member_spec.rb +19 -0
- data/spec/api/user_invitation_list_spec.rb +91 -0
- data/spec/api/user_invitation_spec.rb +19 -0
- data/spec/api/user_list_spec.rb +76 -0
- data/spec/api/user_note_list_spec.rb +91 -0
- data/spec/api/user_note_spec.rb +19 -0
- data/spec/api/user_process_list_spec.rb +90 -0
- data/spec/api/user_process_spec.rb +19 -0
- data/spec/api/user_role_list_spec.rb +92 -0
- data/spec/api/user_role_spec.rb +18 -0
- data/spec/api/user_skill_list_spec.rb +91 -0
- data/spec/api/user_skill_spec.rb +19 -0
- data/spec/api/user_spec.rb +37 -0
- data/spec/api/web_hook_list_spec.rb +75 -0
- data/spec/api/web_hook_spec.rb +19 -0
- data/spec/factories/address.rb +21 -0
- data/spec/factories/address_list.rb +13 -0
- data/spec/factories/checkin.rb +35 -0
- data/spec/factories/checkin_list.rb +13 -0
- data/spec/factories/group.rb +30 -0
- data/spec/factories/group_address.rb +21 -0
- data/spec/factories/group_address_list.rb +13 -0
- data/spec/factories/group_checkin.rb +35 -0
- data/spec/factories/group_checkin_list.rb +13 -0
- data/spec/factories/group_event_attendance.rb +19 -0
- data/spec/factories/group_event_attendance_list.rb +13 -0
- data/spec/factories/group_export.rb +16 -0
- data/spec/factories/group_export_list.rb +13 -0
- data/spec/factories/group_role.rb +19 -0
- data/spec/factories/group_tag.rb +12 -0
- data/spec/factories/role.rb +22 -0
- data/spec/factories/role_list.rb +13 -0
- data/spec/factories/skill.rb +13 -0
- data/spec/factories/skill_list.rb +13 -0
- data/spec/factories/skilled_user_id_list.rb +13 -0
- data/spec/factories/skilled_user_list.rb +13 -0
- data/spec/factories/tag.rb +13 -0
- data/spec/factories/tag_group_list.rb +13 -0
- data/spec/factories/tag_list.rb +13 -0
- data/spec/factories/terminology.rb +10 -0
- data/spec/factories/terminology_list.rb +13 -0
- data/spec/factories/user.rb +51 -0
- data/spec/factories/user_address.rb +19 -0
- data/spec/factories/user_address_list.rb +13 -0
- data/spec/factories/user_admin_privilege.rb +11 -0
- data/spec/factories/user_admin_privilege_list.rb +13 -0
- data/spec/factories/user_barcode.rb +15 -0
- data/spec/factories/user_family_list.rb +13 -0
- data/spec/factories/user_family_member.rb +28 -0
- data/spec/factories/user_invitation.rb +16 -0
- data/spec/factories/user_invitation_list.rb +13 -0
- data/spec/factories/user_list.rb +13 -0
- data/spec/factories/user_note.rb +28 -0
- data/spec/factories/user_note_list.rb +13 -0
- data/spec/factories/user_process.rb +11 -0
- data/spec/factories/user_process_list.rb +13 -0
- data/spec/factories/user_role.rb +17 -0
- data/spec/factories/user_role_list.rb +13 -0
- data/spec/factories/user_skill.rb +10 -0
- data/spec/factories/user_skill_list.rb +13 -0
- data/spec/factories/web_hook.rb +12 -0
- data/spec/factories/web_hook_list.rb +13 -0
- data/spec/functional/the_city_admin_spec.rb +20 -0
- data/spec/readers/user_reader_spec.rb +7 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/writers/skill_writer_spec.rb +0 -0
- data/spec/writers/tag_writer_spec.rb +80 -0
- data/spec/writers/user_writer_spec.rb +80 -0
- data/status.txt +187 -0
- data/test_scripts/addresses.rb +36 -0
- data/test_scripts/barcodes_checkins.rb +45 -0
- data/test_scripts/city_keys.rb +6 -0
- data/test_scripts/familes.rb +83 -0
- data/test_scripts/groups.rb +124 -0
- data/test_scripts/metrics.rb +72 -0
- data/test_scripts/roles.rb +94 -0
- data/test_scripts/skills.rb +55 -0
- data/test_scripts/tags.rb +71 -0
- data/test_scripts/terminology.rb +62 -0
- data/test_scripts/users.rb +325 -0
- data/test_scripts/webhooks.rb +57 -0
- data/thecity_admin_api.gemspec +39 -0
- data/thecity_headers.rb +27 -0
- metadata +238 -3
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.join(Dir.pwd, 'spec', 'spec_helper')
|
2
|
+
|
3
|
+
describe 'TagGroupList' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
it 'should pass if tag group list is empty' do
|
15
|
+
tag_id = 123
|
16
|
+
request_data = FactoryGirl.attributes_for(:tag_group_list, :groups => []).to_json
|
17
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
18
|
+
tag_group_list = TheCity::TagGroupList.new({:tag_id => tag_id})
|
19
|
+
|
20
|
+
tag_group_list.groups.should == []
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it 'should return a valid list of groups' do
|
25
|
+
tag_id = 123
|
26
|
+
page = 2
|
27
|
+
request_data = FactoryGirl.attributes_for(:tag_group_list, {
|
28
|
+
:total_entries => 1,
|
29
|
+
:total_pages => 1,
|
30
|
+
:groups => [FactoryGirl.attributes_for(:group)]
|
31
|
+
}).to_json
|
32
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
33
|
+
tag_group_list = TheCity::TagGroupList.new({:tag_id => tag_id, :page => page})
|
34
|
+
|
35
|
+
tag_group_list.groups.should == ["The Group"]
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
it 'should iterate using *each* method' do
|
40
|
+
tag_id = 123
|
41
|
+
request_data = FactoryGirl.attributes_for(:tag_group_list, {
|
42
|
+
:total_entries => 1,
|
43
|
+
:total_pages => 1,
|
44
|
+
:groups => [FactoryGirl.attributes_for(:group)]
|
45
|
+
}).to_json
|
46
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
47
|
+
tag_group_list = TheCity::TagGroupList.new({:tag_id => tag_id})
|
48
|
+
|
49
|
+
groups = []
|
50
|
+
tag_group_list.each { |group| groups << group.name }
|
51
|
+
tag_group_list.groups.should == ["The Group"]
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
it 'should iterate using *collect* method' do
|
56
|
+
tag_id = 123
|
57
|
+
request_data = FactoryGirl.attributes_for(:tag_group_list, {
|
58
|
+
:total_entries => 1,
|
59
|
+
:total_pages => 1,
|
60
|
+
:groups => [FactoryGirl.attributes_for(:group)]
|
61
|
+
}).to_json
|
62
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
63
|
+
tag_group_list = TheCity::TagGroupList.new({:tag_id => tag_id})
|
64
|
+
|
65
|
+
groups = tag_group_list.collect { |group| group.name }
|
66
|
+
tag_group_list.groups.should == ["The Group"]
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.join(Dir.pwd, 'spec', 'spec_helper')
|
2
|
+
|
3
|
+
describe 'TagList' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
it 'should pass if tag list attribute is not specifed' do
|
15
|
+
request_data = FactoryGirl.attributes_for(:tag_list).to_json
|
16
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
17
|
+
tag_list = TheCity::TagList.new
|
18
|
+
|
19
|
+
tag_list.tags.should == []
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it 'should pass if tag list is empty' do
|
24
|
+
request_data = FactoryGirl.attributes_for(:tag_list, :tags => []).to_json
|
25
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
26
|
+
tag_list = TheCity::TagList.new
|
27
|
+
|
28
|
+
tag_list.tags.should == []
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it 'should return a valid list of tags' do
|
33
|
+
page = 2
|
34
|
+
request_data = FactoryGirl.attributes_for(:tag_list, {
|
35
|
+
:total_entries => 1,
|
36
|
+
:total_pages => 1,
|
37
|
+
:tags => [FactoryGirl.attributes_for(:tag)]
|
38
|
+
}).to_json
|
39
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
40
|
+
tag_list = TheCity::TagList.new({:page => page})
|
41
|
+
|
42
|
+
tag_list.tags.should == ["Evening"]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
it 'should iterate using *each* method' do
|
47
|
+
request_data = FactoryGirl.attributes_for(:tag_list, {
|
48
|
+
:total_entries => 1,
|
49
|
+
:total_pages => 1,
|
50
|
+
:tags => [FactoryGirl.attributes_for(:tag)]
|
51
|
+
}).to_json
|
52
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
53
|
+
tag_list = TheCity::TagList.new
|
54
|
+
|
55
|
+
tags = []
|
56
|
+
tag_list.each { |tag| tags << tag.name }
|
57
|
+
tag_list.tags.should == ["Evening"]
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
it 'should iterate using *collect* method' do
|
62
|
+
request_data = FactoryGirl.attributes_for(:tag_list, {
|
63
|
+
:total_entries => 1,
|
64
|
+
:total_pages => 1,
|
65
|
+
:tags => [FactoryGirl.attributes_for(:tag)]
|
66
|
+
}).to_json
|
67
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
68
|
+
tag_list = TheCity::TagList.new
|
69
|
+
|
70
|
+
tags = tag_list.collect { |tag| tag.name }
|
71
|
+
tag_list.tags.should == ["Evening"]
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.join(Dir.pwd, 'spec', 'spec_helper')
|
2
|
+
|
3
|
+
describe 'TerminologyList' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
it 'should pass if terminology list attribute is not specifed' do
|
15
|
+
request_data = FactoryGirl.attributes_for(:terminology_list).to_json
|
16
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
17
|
+
terminology_list = TheCity::TerminologyList.new
|
18
|
+
|
19
|
+
terminology_list.labels.should == []
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it 'should pass if terminology list is empty' do
|
24
|
+
request_data = FactoryGirl.attributes_for(:terminology_list, :terminologies => []).to_json
|
25
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
26
|
+
terminology_list = TheCity::TerminologyList.new
|
27
|
+
|
28
|
+
terminology_list.labels.should == []
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it 'should return a valid list of terminologies' do
|
33
|
+
request_data = FactoryGirl.attributes_for(:terminology_list, {
|
34
|
+
:total_entries => 1,
|
35
|
+
:total_pages => 1,
|
36
|
+
:labels => [FactoryGirl.attributes_for(:terminology)]
|
37
|
+
}).to_json
|
38
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
39
|
+
terminology_list = TheCity::TerminologyList.new({:page => 2})
|
40
|
+
terminology_list.labels.should == ['CG']
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
it 'should iterate using *each* method' do
|
45
|
+
request_data = FactoryGirl.attributes_for(:terminology_list, {
|
46
|
+
:total_entries => 1,
|
47
|
+
:total_pages => 1,
|
48
|
+
:labels => [FactoryGirl.attributes_for(:terminology)]
|
49
|
+
}).to_json
|
50
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
51
|
+
terminology_list = TheCity::TerminologyList.new
|
52
|
+
|
53
|
+
terminologies = []
|
54
|
+
terminology_list.each { |terminology| terminologies << terminology.label }
|
55
|
+
terminology_list.labels.should == ['CG']
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it 'should iterate using *collect* method' do
|
60
|
+
request_data = FactoryGirl.attributes_for(:terminology_list, {
|
61
|
+
:total_entries => 1,
|
62
|
+
:total_pages => 1,
|
63
|
+
:labels => [FactoryGirl.attributes_for(:terminology)]
|
64
|
+
}).to_json
|
65
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
66
|
+
terminology_list = TheCity::TerminologyList.new
|
67
|
+
|
68
|
+
terminologies = terminology_list.collect { |terminology| terminology.label }
|
69
|
+
terminology_list.labels.should == ['CG']
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.join(Dir.pwd, 'spec', 'spec_helper')
|
2
|
+
|
3
|
+
describe 'UserAddressList' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
it 'should pass if user address list attribute is not specifed' do
|
15
|
+
user_id = 123
|
16
|
+
request_data = FactoryGirl.attributes_for(:user_address_list, {
|
17
|
+
:total_entries => 1,
|
18
|
+
:total_pages => 1,
|
19
|
+
:addresses => [FactoryGirl.attributes_for(:user_address)]
|
20
|
+
}).to_json
|
21
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
22
|
+
address_list = TheCity::UserAddressList.new({:user_id => user_id})
|
23
|
+
|
24
|
+
address = address_list[0]
|
25
|
+
address.city.should == "Seattle"
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
it 'should pass if user address list is empty' do
|
30
|
+
user_id = 123
|
31
|
+
request_data = FactoryGirl.attributes_for(:user_address_list, {
|
32
|
+
:total_entries => 1,
|
33
|
+
:total_pages => 1,
|
34
|
+
:addresses => []
|
35
|
+
}).to_json
|
36
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
37
|
+
address_list = TheCity::UserAddressList.new({:user_id => user_id})
|
38
|
+
|
39
|
+
address_list.empty?.should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
it 'should return a valid list of user addresses' do
|
44
|
+
user_id = 123
|
45
|
+
page = 2
|
46
|
+
request_data = FactoryGirl.attributes_for(:user_address_list, {
|
47
|
+
:total_entries => 1,
|
48
|
+
:total_pages => 1,
|
49
|
+
:addresses => [FactoryGirl.attributes_for(:user_address)]
|
50
|
+
}).to_json
|
51
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
52
|
+
address_list = TheCity::UserAddressList.new({:user_id => user_id, :page => page})
|
53
|
+
|
54
|
+
address = address_list[0]
|
55
|
+
address.city.should == "Seattle"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it 'should iterate using *each* method' do
|
60
|
+
user_id = 123
|
61
|
+
request_data = FactoryGirl.attributes_for(:user_address_list, {
|
62
|
+
:total_entries => 1,
|
63
|
+
:total_pages => 1,
|
64
|
+
:addresses => [FactoryGirl.attributes_for(:user_address)]
|
65
|
+
}).to_json
|
66
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
67
|
+
address_list = TheCity::UserAddressList.new({:user_id => user_id})
|
68
|
+
|
69
|
+
addresses = []
|
70
|
+
address_list.each { |address| addresses << address.city }
|
71
|
+
addresses.should == ["Seattle"]
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
it 'should iterate using *collect* method' do
|
76
|
+
user_id = 123
|
77
|
+
request_data = FactoryGirl.attributes_for(:user_address_list, {
|
78
|
+
:total_entries => 1,
|
79
|
+
:total_pages => 1,
|
80
|
+
:addresses => [FactoryGirl.attributes_for(:user_address)]
|
81
|
+
}).to_json
|
82
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
83
|
+
address_list = TheCity::UserAddressList.new({:user_id => user_id})
|
84
|
+
|
85
|
+
addresses = address_list.collect { |address| address.city }
|
86
|
+
addresses.should == ["Seattle"]
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.join(Dir.pwd, 'spec', 'spec_helper')
|
2
|
+
|
3
|
+
describe 'UserAdminPrivilegeList' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
simulate_connection_to_server
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
it 'should pass if user admin_privilege list attribute is not specifed' do
|
15
|
+
user_id = 123
|
16
|
+
request_data = FactoryGirl.attributes_for(:user_admin_privilege_list, {
|
17
|
+
:total_entries => 1,
|
18
|
+
:total_pages => 1,
|
19
|
+
:account_roles => [FactoryGirl.attributes_for(:user_admin_privilege)]
|
20
|
+
}).to_json
|
21
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
22
|
+
admin_privilege_list = TheCity::UserAdminPrivilegeList.new({:user_id => user_id})
|
23
|
+
|
24
|
+
admin_privilege = admin_privilege_list[0]
|
25
|
+
admin_privilege.title.should == "Designer"
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
it 'should pass if user admin_privilege list is empty' do
|
30
|
+
user_id = 123
|
31
|
+
request_data = FactoryGirl.attributes_for(:user_admin_privilege_list, {
|
32
|
+
:total_entries => 1,
|
33
|
+
:total_pages => 1,
|
34
|
+
:account_roles => []
|
35
|
+
}).to_json
|
36
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
37
|
+
admin_privilege_list = TheCity::UserAdminPrivilegeList.new({:user_id => user_id})
|
38
|
+
|
39
|
+
admin_privilege_list.empty?.should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
it 'should return a valid list of user admin_privileges' do
|
44
|
+
user_id = 123
|
45
|
+
page = 2
|
46
|
+
request_data = FactoryGirl.attributes_for(:user_admin_privilege_list, {
|
47
|
+
:total_entries => 1,
|
48
|
+
:total_pages => 1,
|
49
|
+
:account_roles => [FactoryGirl.attributes_for(:user_admin_privilege)]
|
50
|
+
}).to_json
|
51
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
52
|
+
admin_privilege_list = TheCity::UserAdminPrivilegeList.new({:user_id => user_id, :page => page})
|
53
|
+
|
54
|
+
admin_privilege = admin_privilege_list[0]
|
55
|
+
admin_privilege.title.should == "Designer"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it 'should iterate using *each* method' do
|
60
|
+
user_id = 123
|
61
|
+
request_data = FactoryGirl.attributes_for(:user_admin_privilege_list, {
|
62
|
+
:total_entries => 1,
|
63
|
+
:total_pages => 1,
|
64
|
+
:account_roles => [FactoryGirl.attributes_for(:user_admin_privilege)]
|
65
|
+
}).to_json
|
66
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
67
|
+
admin_privilege_list = TheCity::UserAdminPrivilegeList.new({:user_id => user_id})
|
68
|
+
|
69
|
+
admin_privileges = []
|
70
|
+
admin_privilege_list.each { |admin_privilege| admin_privileges << admin_privilege.title }
|
71
|
+
admin_privileges.should == ["Designer"]
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
it 'should iterate using *collect* method' do
|
76
|
+
user_id = 123
|
77
|
+
request_data = FactoryGirl.attributes_for(:user_admin_privilege_list, {
|
78
|
+
:total_entries => 1,
|
79
|
+
:total_pages => 1,
|
80
|
+
:account_roles => [FactoryGirl.attributes_for(:user_admin_privilege)]
|
81
|
+
}).to_json
|
82
|
+
TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
|
83
|
+
admin_privilege_list = TheCity::UserAdminPrivilegeList.new({:user_id => user_id})
|
84
|
+
|
85
|
+
admin_privileges = admin_privilege_list.collect { |admin_privilege| admin_privilege.title }
|
86
|
+
admin_privileges.should == ["Designer"]
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|