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.
Files changed (135) hide show
  1. data/.autotest +9 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.rvmrc +1 -0
  5. data/.yardoc/checksums +50 -0
  6. data/.yardoc/object_types +0 -0
  7. data/.yardoc/objects/root.dat +0 -0
  8. data/.yardoc/proxy_types +0 -0
  9. data/Gemfile +11 -0
  10. data/Gemfile.lock +51 -0
  11. data/README +1 -0
  12. data/Rakefile +32 -0
  13. data/index.rb +123 -0
  14. data/lib/common.rb +163 -72
  15. data/lib/the_city_admin.rb +2 -2
  16. data/notes.txt +21 -0
  17. data/spec/api/address_list_spec.rb +0 -0
  18. data/spec/api/address_spec.rb +0 -0
  19. data/spec/api/group_address_list_spec.rb +93 -0
  20. data/spec/api/group_address_spec.rb +19 -0
  21. data/spec/api/group_checkin_list_spec.rb +93 -0
  22. data/spec/api/group_event_attendance_list_spec.rb +93 -0
  23. data/spec/api/group_export_spec.rb +19 -0
  24. data/spec/api/group_invitation_list_spec.rb +23 -0
  25. data/spec/api/group_invitation_spec.rb +19 -0
  26. data/spec/api/group_list_spec.rb +23 -0
  27. data/spec/api/group_role_list_spec.rb +23 -0
  28. data/spec/api/group_role_spec.rb +19 -0
  29. data/spec/api/group_spec.rb +19 -0
  30. data/spec/api/group_tag_list_spec.rb +23 -0
  31. data/spec/api/group_tag_spec.rb +19 -0
  32. data/spec/api/metric_list_spec.rb +22 -0
  33. data/spec/api/metric_measurement_list_spec.rb +23 -0
  34. data/spec/api/metric_measurement_spec.rb +19 -0
  35. data/spec/api/metric_spec.rb +19 -0
  36. data/spec/api/role_list_spec.rb +75 -0
  37. data/spec/api/role_spec.rb +19 -0
  38. data/spec/api/skill_list_spec.rb +76 -0
  39. data/spec/api/skilled_user_id_list_spec.rb +82 -0
  40. data/spec/api/skilled_user_list_spec.rb +82 -0
  41. data/spec/api/tag_group_list_spec.rb +72 -0
  42. data/spec/api/tag_list_spec.rb +77 -0
  43. data/spec/api/tag_spec.rb +19 -0
  44. data/spec/api/terminology_list_spec.rb +75 -0
  45. data/spec/api/terminology_spec.rb +19 -0
  46. data/spec/api/user_address_list_spec.rb +92 -0
  47. data/spec/api/user_address_spec.rb +19 -0
  48. data/spec/api/user_admin_privilege_list_spec.rb +94 -0
  49. data/spec/api/user_admin_privilege_spec.rb +19 -0
  50. data/spec/api/user_barcode_spec.rb +19 -0
  51. data/spec/api/user_family_list_spec.rb +91 -0
  52. data/spec/api/user_family_member_spec.rb +19 -0
  53. data/spec/api/user_invitation_list_spec.rb +91 -0
  54. data/spec/api/user_invitation_spec.rb +19 -0
  55. data/spec/api/user_list_spec.rb +76 -0
  56. data/spec/api/user_note_list_spec.rb +91 -0
  57. data/spec/api/user_note_spec.rb +19 -0
  58. data/spec/api/user_process_list_spec.rb +90 -0
  59. data/spec/api/user_process_spec.rb +19 -0
  60. data/spec/api/user_role_list_spec.rb +92 -0
  61. data/spec/api/user_role_spec.rb +18 -0
  62. data/spec/api/user_skill_list_spec.rb +91 -0
  63. data/spec/api/user_skill_spec.rb +19 -0
  64. data/spec/api/user_spec.rb +37 -0
  65. data/spec/api/web_hook_list_spec.rb +75 -0
  66. data/spec/api/web_hook_spec.rb +19 -0
  67. data/spec/factories/address.rb +21 -0
  68. data/spec/factories/address_list.rb +13 -0
  69. data/spec/factories/checkin.rb +35 -0
  70. data/spec/factories/checkin_list.rb +13 -0
  71. data/spec/factories/group.rb +30 -0
  72. data/spec/factories/group_address.rb +21 -0
  73. data/spec/factories/group_address_list.rb +13 -0
  74. data/spec/factories/group_checkin.rb +35 -0
  75. data/spec/factories/group_checkin_list.rb +13 -0
  76. data/spec/factories/group_event_attendance.rb +19 -0
  77. data/spec/factories/group_event_attendance_list.rb +13 -0
  78. data/spec/factories/group_export.rb +16 -0
  79. data/spec/factories/group_export_list.rb +13 -0
  80. data/spec/factories/group_role.rb +19 -0
  81. data/spec/factories/group_tag.rb +12 -0
  82. data/spec/factories/role.rb +22 -0
  83. data/spec/factories/role_list.rb +13 -0
  84. data/spec/factories/skill.rb +13 -0
  85. data/spec/factories/skill_list.rb +13 -0
  86. data/spec/factories/skilled_user_id_list.rb +13 -0
  87. data/spec/factories/skilled_user_list.rb +13 -0
  88. data/spec/factories/tag.rb +13 -0
  89. data/spec/factories/tag_group_list.rb +13 -0
  90. data/spec/factories/tag_list.rb +13 -0
  91. data/spec/factories/terminology.rb +10 -0
  92. data/spec/factories/terminology_list.rb +13 -0
  93. data/spec/factories/user.rb +51 -0
  94. data/spec/factories/user_address.rb +19 -0
  95. data/spec/factories/user_address_list.rb +13 -0
  96. data/spec/factories/user_admin_privilege.rb +11 -0
  97. data/spec/factories/user_admin_privilege_list.rb +13 -0
  98. data/spec/factories/user_barcode.rb +15 -0
  99. data/spec/factories/user_family_list.rb +13 -0
  100. data/spec/factories/user_family_member.rb +28 -0
  101. data/spec/factories/user_invitation.rb +16 -0
  102. data/spec/factories/user_invitation_list.rb +13 -0
  103. data/spec/factories/user_list.rb +13 -0
  104. data/spec/factories/user_note.rb +28 -0
  105. data/spec/factories/user_note_list.rb +13 -0
  106. data/spec/factories/user_process.rb +11 -0
  107. data/spec/factories/user_process_list.rb +13 -0
  108. data/spec/factories/user_role.rb +17 -0
  109. data/spec/factories/user_role_list.rb +13 -0
  110. data/spec/factories/user_skill.rb +10 -0
  111. data/spec/factories/user_skill_list.rb +13 -0
  112. data/spec/factories/web_hook.rb +12 -0
  113. data/spec/factories/web_hook_list.rb +13 -0
  114. data/spec/functional/the_city_admin_spec.rb +20 -0
  115. data/spec/readers/user_reader_spec.rb +7 -0
  116. data/spec/spec_helper.rb +31 -0
  117. data/spec/writers/skill_writer_spec.rb +0 -0
  118. data/spec/writers/tag_writer_spec.rb +80 -0
  119. data/spec/writers/user_writer_spec.rb +80 -0
  120. data/status.txt +187 -0
  121. data/test_scripts/addresses.rb +36 -0
  122. data/test_scripts/barcodes_checkins.rb +45 -0
  123. data/test_scripts/city_keys.rb +6 -0
  124. data/test_scripts/familes.rb +83 -0
  125. data/test_scripts/groups.rb +124 -0
  126. data/test_scripts/metrics.rb +72 -0
  127. data/test_scripts/roles.rb +94 -0
  128. data/test_scripts/skills.rb +55 -0
  129. data/test_scripts/tags.rb +71 -0
  130. data/test_scripts/terminology.rb +62 -0
  131. data/test_scripts/users.rb +325 -0
  132. data/test_scripts/webhooks.rb +57 -0
  133. data/thecity_admin_api.gemspec +39 -0
  134. data/thecity_headers.rb +27 -0
  135. metadata +238 -3
@@ -0,0 +1,19 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserAdminPrivilege' 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 ....'
15
+
16
+
17
+ end
18
+
19
+
@@ -0,0 +1,19 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserBarcode' 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 ....'
15
+
16
+
17
+ end
18
+
19
+
@@ -0,0 +1,91 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserFamilyList' 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 family list attribute is not specifed' do
15
+ user_id = 123
16
+ request_data = FactoryGirl.attributes_for(:user_family_list, {
17
+ :total_entries => 1,
18
+ :total_pages => 1,
19
+ :family_members => [FactoryGirl.attributes_for(:user_family_member)]
20
+ }).to_json
21
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
22
+ family_list = TheCity::UserFamilyList.new({:user_id => user_id})
23
+
24
+ family = family_list[0]
25
+ family.name.should == "Pastor Sam Shepherd"
26
+ end
27
+
28
+
29
+ it 'should pass if user family list is empty' do
30
+ user_id = 123
31
+ request_data = FactoryGirl.attributes_for(:user_family_list, {
32
+ :total_entries => 1,
33
+ :total_pages => 1,
34
+ :family_members => []
35
+ }).to_json
36
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
37
+ family_list = TheCity::UserFamilyList.new({:user_id => user_id})
38
+
39
+ family_list.empty?.should be_true
40
+ end
41
+
42
+
43
+ it 'should return a valid list of user family_members' do
44
+ user_id = 123
45
+ page = 2
46
+ request_data = FactoryGirl.attributes_for(:user_family_list, {
47
+ :total_entries => 1,
48
+ :total_pages => 1,
49
+ :family_members => [FactoryGirl.attributes_for(:user_family_member)]
50
+ }).to_json
51
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
52
+ family_list = TheCity::UserFamilyList.new({:user_id => user_id, :page => page})
53
+
54
+ family = family_list[0]
55
+ family.name.should == "Pastor Sam Shepherd"
56
+ end
57
+
58
+
59
+ it 'should iterate using *each* method' do
60
+ user_id = 123
61
+ request_data = FactoryGirl.attributes_for(:user_family_list, {
62
+ :total_entries => 1,
63
+ :total_pages => 1,
64
+ :family_members => [FactoryGirl.attributes_for(:user_family_member)]
65
+ }).to_json
66
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
67
+ family_list = TheCity::UserFamilyList.new({:user_id => user_id})
68
+
69
+ family_members = []
70
+ family_list.each { |family| family_members << family.name }
71
+ family_members.should == ["Pastor Sam Shepherd"]
72
+ end
73
+
74
+
75
+ it 'should iterate using *collect* method' do
76
+ user_id = 123
77
+ request_data = FactoryGirl.attributes_for(:user_family_list, {
78
+ :total_entries => 1,
79
+ :total_pages => 1,
80
+ :family_members => [FactoryGirl.attributes_for(:user_family_member)]
81
+ }).to_json
82
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
83
+ family_list = TheCity::UserFamilyList.new({:user_id => user_id})
84
+
85
+ family_members = family_list.collect { |family| family.name }
86
+ family_members.should == ["Pastor Sam Shepherd"]
87
+ end
88
+
89
+ end
90
+
91
+
@@ -0,0 +1,19 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserFamilyMember' 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 ....'
15
+
16
+
17
+ end
18
+
19
+
@@ -0,0 +1,91 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserInvitationList' 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 invitation list attribute is not specifed' do
15
+ user_id = 123
16
+ request_data = FactoryGirl.attributes_for(:user_invitation_list, {
17
+ :total_entries => 1,
18
+ :total_pages => 1,
19
+ :invitations => [FactoryGirl.attributes_for(:user_invitation)]
20
+ }).to_json
21
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
22
+ invitation_list = TheCity::UserInvitationList.new({:user_id => user_id})
23
+
24
+ invitation = invitation_list[0]
25
+ invitation.source.should == "API Invite | Group A (17543) on 2012-02-06 at 16:54"
26
+ end
27
+
28
+
29
+ it 'should pass if user invitation list is empty' do
30
+ user_id = 123
31
+ request_data = FactoryGirl.attributes_for(:user_invitation_list, {
32
+ :total_entries => 1,
33
+ :total_pages => 1,
34
+ :invitations => []
35
+ }).to_json
36
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
37
+ invitation_list = TheCity::UserInvitationList.new({:user_id => user_id})
38
+
39
+ invitation_list.empty?.should be_true
40
+ end
41
+
42
+
43
+ it 'should return a valid list of user invitations' do
44
+ user_id = 123
45
+ page = 2
46
+ request_data = FactoryGirl.attributes_for(:user_invitation_list, {
47
+ :total_entries => 1,
48
+ :total_pages => 1,
49
+ :invitations => [FactoryGirl.attributes_for(:user_invitation)]
50
+ }).to_json
51
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
52
+ invitation_list = TheCity::UserInvitationList.new({:user_id => user_id, :page => 2})
53
+
54
+ invitation = invitation_list[0]
55
+ invitation.source.should == "API Invite | Group A (17543) on 2012-02-06 at 16:54"
56
+ end
57
+
58
+
59
+ it 'should iterate using *each* method' do
60
+ user_id = 123
61
+ request_data = FactoryGirl.attributes_for(:user_invitation_list, {
62
+ :total_entries => 1,
63
+ :total_pages => 1,
64
+ :invitations => [FactoryGirl.attributes_for(:user_invitation)]
65
+ }).to_json
66
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
67
+ invitation_list = TheCity::UserInvitationList.new({:user_id => user_id})
68
+
69
+ invitations = []
70
+ invitation_list.each { |invitation| invitations << invitation.source }
71
+ invitations.should == ["API Invite | Group A (17543) on 2012-02-06 at 16:54"]
72
+ end
73
+
74
+
75
+ it 'should iterate using *collect* method' do
76
+ user_id = 123
77
+ request_data = FactoryGirl.attributes_for(:user_invitation_list, {
78
+ :total_entries => 1,
79
+ :total_pages => 1,
80
+ :invitations => [FactoryGirl.attributes_for(:user_invitation)]
81
+ }).to_json
82
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
83
+ invitation_list = TheCity::UserInvitationList.new({:user_id => user_id})
84
+
85
+ invitations = invitation_list.collect { |invitation| invitation.source }
86
+ invitations.should == ["API Invite | Group A (17543) on 2012-02-06 at 16:54"]
87
+ end
88
+
89
+ end
90
+
91
+
@@ -0,0 +1,19 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserInvitation' 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 ....'
15
+
16
+
17
+ end
18
+
19
+
@@ -0,0 +1,76 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserList' 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 list attribute is not specifed' do
15
+ request_data = FactoryGirl.attributes_for(:user_list).to_json
16
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
17
+ user_list = TheCity::UserList.new
18
+
19
+ user_list.names.should == []
20
+ end
21
+
22
+
23
+ it 'should pass if user list is empty' do
24
+ request_data = FactoryGirl.attributes_for(:user_list, :users => []).to_json
25
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
26
+ user_list = TheCity::UserList.new
27
+
28
+ user_list.names.should == []
29
+ end
30
+
31
+
32
+ it 'should return a valid list of users' do
33
+ request_data = FactoryGirl.attributes_for(:user_list, {
34
+ :total_entries => 1,
35
+ :total_pages => 1,
36
+ :users => [FactoryGirl.attributes_for(:user)]
37
+ }).to_json
38
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
39
+ user_list = TheCity::UserList.new({:page => 2})
40
+
41
+ user_list.names.should == ["Sam Shepherd"]
42
+ end
43
+
44
+
45
+ it 'should iterate using *each* method' do
46
+ request_data = FactoryGirl.attributes_for(:user_list, {
47
+ :total_entries => 1,
48
+ :total_pages => 1,
49
+ :users => [FactoryGirl.attributes_for(:user)]
50
+ }).to_json
51
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
52
+ user_list = TheCity::UserList.new
53
+
54
+ users = []
55
+ user_list.each { |user| users << user.full_name }
56
+ user_list.names.should == ["Sam Shepherd"]
57
+ end
58
+
59
+
60
+ it 'should iterate using *collect* method' do
61
+ request_data = FactoryGirl.attributes_for(:user_list, {
62
+ :total_entries => 1,
63
+ :total_pages => 1,
64
+ :users => [FactoryGirl.attributes_for(:user)]
65
+ }).to_json
66
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
67
+ user_list = TheCity::UserList.new
68
+
69
+ users = user_list.collect { |user| user.full_name }
70
+ user_list.names.should == ["Sam Shepherd"]
71
+ end
72
+
73
+
74
+ end
75
+
76
+
@@ -0,0 +1,91 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserNoteList' 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 note list attribute is not specifed' do
15
+ user_id = 123
16
+ request_data = FactoryGirl.attributes_for(:user_note_list, {
17
+ :total_entries => 1,
18
+ :total_pages => 1,
19
+ :notes => [FactoryGirl.attributes_for(:user_note)]
20
+ }).to_json
21
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
22
+ note_list = TheCity::UserNoteList.new({:user_id => user_id})
23
+
24
+ note = note_list[0]
25
+ note.body.should == "Deaconship is complete"
26
+ end
27
+
28
+
29
+ it 'should pass if user note list is empty' do
30
+ user_id = 123
31
+ request_data = FactoryGirl.attributes_for(:user_note_list, {
32
+ :total_entries => 1,
33
+ :total_pages => 1,
34
+ :notes => []
35
+ }).to_json
36
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
37
+ note_list = TheCity::UserNoteList.new({:user_id => user_id})
38
+
39
+ note_list.empty?.should be_true
40
+ end
41
+
42
+
43
+ it 'should return a valid list of user notes' do
44
+ user_id = 123
45
+ page = 2
46
+ request_data = FactoryGirl.attributes_for(:user_note_list, {
47
+ :total_entries => 1,
48
+ :total_pages => 1,
49
+ :notes => [FactoryGirl.attributes_for(:user_note)]
50
+ }).to_json
51
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
52
+ note_list = TheCity::UserNoteList.new({:user_id => user_id, :page => page})
53
+
54
+ note = note_list[0]
55
+ note.body.should == "Deaconship is complete"
56
+ end
57
+
58
+
59
+ it 'should iterate using *each* method' do
60
+ user_id = 123
61
+ request_data = FactoryGirl.attributes_for(:user_note_list, {
62
+ :total_entries => 1,
63
+ :total_pages => 1,
64
+ :notes => [FactoryGirl.attributes_for(:user_note)]
65
+ }).to_json
66
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
67
+ note_list = TheCity::UserNoteList.new({:user_id => user_id})
68
+
69
+ notes = []
70
+ note_list.each { |note| notes << note.body }
71
+ notes.should == ["Deaconship is complete"]
72
+ end
73
+
74
+
75
+ it 'should iterate using *collect* method' do
76
+ user_id = 123
77
+ request_data = FactoryGirl.attributes_for(:user_note_list, {
78
+ :total_entries => 1,
79
+ :total_pages => 1,
80
+ :notes => [FactoryGirl.attributes_for(:user_note)]
81
+ }).to_json
82
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
83
+ note_list = TheCity::UserNoteList.new({:user_id => user_id})
84
+
85
+ notes = note_list.collect { |note| note.body }
86
+ notes.should == ["Deaconship is complete"]
87
+ end
88
+
89
+ end
90
+
91
+
@@ -0,0 +1,19 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'UserNote' 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 ....'
15
+
16
+
17
+ end
18
+
19
+