osm 1.2.17 → 1.2.18.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +35 -0
- data/gemfiles/rails3 +1 -1
- data/lib/hash_validator.rb +12 -4
- data/lib/osm/api.rb +5 -6
- data/lib/osm/member.rb +503 -171
- data/lib/osm/section.rb +1 -26
- data/lib/validity_validator.rb +11 -0
- data/osm.gemspec +1 -1
- data/spec/array_of_validator_spec.rb +1 -1
- data/spec/hash_validator_spec.rb +133 -0
- data/spec/osm/activity_spec.rb +7 -7
- data/spec/osm/api_access_spec.rb +1 -1
- data/spec/osm/api_spec.rb +4 -4
- data/spec/osm/badge_spec.rb +62 -62
- data/spec/osm/badges_spec.rb +4 -4
- data/spec/osm/budget_spec.rb +8 -8
- data/spec/osm/event_spec.rb +42 -42
- data/spec/osm/flexi_record_spec.rb +18 -18
- data/spec/osm/giftaid_spec.rb +7 -7
- data/spec/osm/grouping_spec.rb +5 -5
- data/spec/osm/invoice_spec.rb +32 -32
- data/spec/osm/meeting_spec.rb +10 -10
- data/spec/osm/member_spec.rb +316 -167
- data/spec/osm/model_spec.rb +31 -31
- data/spec/osm/register_spec.rb +15 -15
- data/spec/osm/section_spec.rb +28 -71
- data/spec/osm/sms_spec.rb +1 -1
- data/spec/osm/term_spec.rb +31 -31
- data/spec/validity_validator_spec.rb +32 -0
- data/version.rb +1 -1
- metadata +13 -10
data/spec/osm/model_spec.rb
CHANGED
@@ -67,12 +67,12 @@ describe "Model" do
|
|
67
67
|
|
68
68
|
it "Checks for existance" do
|
69
69
|
OsmTest::Cache.should_receive('exist?').with('OSMAPI-osm-key') { true }
|
70
|
-
ModelTester.cache('exist?', @api, 'key').should
|
70
|
+
ModelTester.cache('exist?', @api, 'key').should == true
|
71
71
|
end
|
72
72
|
|
73
73
|
it "Writes" do
|
74
74
|
OsmTest::Cache.should_receive('write').with('OSMAPI-osm-key', 'data', {:expires_in=>600}) { true }
|
75
|
-
ModelTester.cache('write', @api, 'key', 'data').should
|
75
|
+
ModelTester.cache('write', @api, 'key', 'data').should == true
|
76
76
|
end
|
77
77
|
|
78
78
|
it "Reads" do
|
@@ -82,15 +82,15 @@ describe "Model" do
|
|
82
82
|
|
83
83
|
it "Deletes" do
|
84
84
|
OsmTest::Cache.should_receive('delete').with('OSMAPI-osm-key') { true }
|
85
|
-
ModelTester.cache('delete', @api, 'key').should
|
85
|
+
ModelTester.cache('delete', @api, 'key').should == true
|
86
86
|
end
|
87
87
|
|
88
88
|
it "Behaves when cache is nil (no caching)" do
|
89
89
|
Osm::Model.configure({:cache => nil})
|
90
|
-
ModelTester.cache('exist?', @api, 'key').should
|
91
|
-
ModelTester.cache('write', @api, 'key', 'data').should
|
90
|
+
ModelTester.cache('exist?', @api, 'key').should == false
|
91
|
+
ModelTester.cache('write', @api, 'key', 'data').should == false
|
92
92
|
ModelTester.cache('read', @api, 'key').should be_nil
|
93
|
-
ModelTester.cache('delete', @api, 'key').should
|
93
|
+
ModelTester.cache('delete', @api, 'key').should == true
|
94
94
|
end
|
95
95
|
|
96
96
|
it "Builds a key from an array" do
|
@@ -148,33 +148,33 @@ describe "Model" do
|
|
148
148
|
end
|
149
149
|
|
150
150
|
it ">" do
|
151
|
-
(@mt1 > @mt2).should
|
152
|
-
(@mt2 > @mt1).should
|
153
|
-
(@mt2 > @mt2a).should
|
151
|
+
(@mt1 > @mt2).should == false
|
152
|
+
(@mt2 > @mt1).should == true
|
153
|
+
(@mt2 > @mt2a).should == false
|
154
154
|
end
|
155
155
|
|
156
156
|
it ">=" do
|
157
|
-
(@mt1 >= @mt2).should
|
158
|
-
(@mt2 >= @mt1).should
|
159
|
-
(@mt2 >= @mt2a).should
|
157
|
+
(@mt1 >= @mt2).should == false
|
158
|
+
(@mt2 >= @mt1).should == true
|
159
|
+
(@mt2 >= @mt2a).should == true
|
160
160
|
end
|
161
161
|
|
162
162
|
it "<" do
|
163
|
-
(@mt1 < @mt2).should
|
164
|
-
(@mt2 < @mt1).should
|
165
|
-
(@mt2 < @mt2a).should
|
163
|
+
(@mt1 < @mt2).should == true
|
164
|
+
(@mt2 < @mt1).should == false
|
165
|
+
(@mt2 < @mt2a).should == false
|
166
166
|
end
|
167
167
|
|
168
168
|
it "<=" do
|
169
|
-
(@mt1 <= @mt2).should
|
170
|
-
(@mt2 <= @mt1).should
|
171
|
-
(@mt2 <= @mt2a).should
|
169
|
+
(@mt1 <= @mt2).should == true
|
170
|
+
(@mt2 <= @mt1).should == false
|
171
|
+
(@mt2 <= @mt2a).should == true
|
172
172
|
end
|
173
173
|
|
174
174
|
it "between" do
|
175
|
-
@mt2.between?(@mt1, @mt3).should
|
176
|
-
@mt1.between?(@mt1, @mt3).should
|
177
|
-
@mt3.between?(@mt1, @mt3).should
|
175
|
+
@mt2.between?(@mt1, @mt3).should == true
|
176
|
+
@mt1.between?(@mt1, @mt3).should == false
|
177
|
+
@mt3.between?(@mt1, @mt3).should == false
|
178
178
|
end
|
179
179
|
|
180
180
|
end
|
@@ -188,15 +188,15 @@ describe "Model" do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it "Has permission" do
|
191
|
-
Osm::Model.user_has_permission?(@api, :bar, :foo, 1).should
|
191
|
+
Osm::Model.user_has_permission?(@api, :bar, :foo, 1).should == true
|
192
192
|
end
|
193
193
|
|
194
194
|
it "Doesn't have the level of permission" do
|
195
|
-
Osm::Model.user_has_permission?(@api, :barbar, :foo, 1).should
|
195
|
+
Osm::Model.user_has_permission?(@api, :barbar, :foo, 1).should == false
|
196
196
|
end
|
197
197
|
|
198
198
|
it "Doesn't have access to section" do
|
199
|
-
Osm::Model.user_has_permission?(@api, :bar, :foo, 2).should
|
199
|
+
Osm::Model.user_has_permission?(@api, :bar, :foo, 2).should == false
|
200
200
|
end
|
201
201
|
|
202
202
|
end
|
@@ -212,16 +212,16 @@ describe "Model" do
|
|
212
212
|
end
|
213
213
|
|
214
214
|
it "Has permission" do
|
215
|
-
Osm::Model.api_has_permission?(@api, :bar, :foo, 1).should
|
215
|
+
Osm::Model.api_has_permission?(@api, :bar, :foo, 1).should == true
|
216
216
|
end
|
217
217
|
|
218
218
|
it "Doesn't have the level of permission" do
|
219
|
-
Osm::Model.api_has_permission?(@api, :barbar, :foo, 1).should
|
219
|
+
Osm::Model.api_has_permission?(@api, :barbar, :foo, 1).should == false
|
220
220
|
end
|
221
221
|
|
222
222
|
it "Doesn't have access to the section" do
|
223
223
|
Osm::ApiAccess.stub(:get_ours).and_return(nil)
|
224
|
-
Osm::Model.api_has_permission?(@api, :bar, :foo, 2).should
|
224
|
+
Osm::Model.api_has_permission?(@api, :bar, :foo, 2).should == false
|
225
225
|
end
|
226
226
|
|
227
227
|
end
|
@@ -233,7 +233,7 @@ describe "Model" do
|
|
233
233
|
options = {:foo => :bar}
|
234
234
|
expect(Osm::Model).to receive('user_has_permission?').with(@api, :can_do, :can_to, section, options).and_return(true)
|
235
235
|
expect(Osm::Model).to receive('api_has_permission?').with(@api, :can_do, :can_to, section, options).and_return(true)
|
236
|
-
Osm::Model.has_permission?(@api, :can_do, :can_to, section, options).should
|
236
|
+
Osm::Model.has_permission?(@api, :can_do, :can_to, section, options).should == true
|
237
237
|
end
|
238
238
|
|
239
239
|
describe "Otherwise returns false" do
|
@@ -241,7 +241,7 @@ describe "Model" do
|
|
241
241
|
it "User #{user ? 'can' : "can't"} and #{api ? 'has' : "hasn't"} given access" do
|
242
242
|
Osm::Model.stub('user_has_permission?').and_return(user)
|
243
243
|
Osm::Model.stub('api_has_permission?').and_return(api)
|
244
|
-
Osm::Model.has_permission?(@api, :can_do, :can_to, Osm::Section.new).should
|
244
|
+
Osm::Model.has_permission?(@api, :can_do, :can_to, Osm::Section.new).should == false
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -255,11 +255,11 @@ describe "Model" do
|
|
255
255
|
end
|
256
256
|
|
257
257
|
it "Has access" do
|
258
|
-
Osm::Model.has_access_to_section?(@api, 1).should
|
258
|
+
Osm::Model.has_access_to_section?(@api, 1).should == true
|
259
259
|
end
|
260
260
|
|
261
261
|
it "Doesn't have access" do
|
262
|
-
Osm::Model.has_access_to_section?(@api, 2).should
|
262
|
+
Osm::Model.has_access_to_section?(@api, 2).should == false
|
263
263
|
end
|
264
264
|
|
265
265
|
end
|
data/spec/osm/register_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe "Register" do
|
|
15
15
|
field.id.should == 'machine_name'
|
16
16
|
field.name.should == 'Human name'
|
17
17
|
field.tooltip.should == 'Tooltip'
|
18
|
-
field.valid?.should
|
18
|
+
field.valid?.should == true
|
19
19
|
end
|
20
20
|
|
21
21
|
it "Sorts Field by id" do
|
@@ -51,7 +51,7 @@ describe "Register" do
|
|
51
51
|
Date.new(2012, 01, 10) => :yes,
|
52
52
|
Date.new(2012, 01, 24) => :unadvised_absent
|
53
53
|
}
|
54
|
-
rd.valid?.should
|
54
|
+
rd.valid?.should == true
|
55
55
|
end
|
56
56
|
|
57
57
|
it "Sorts Attendance by section_id, grouping_id, last_name then first_name" do
|
@@ -67,16 +67,16 @@ describe "Register" do
|
|
67
67
|
|
68
68
|
it "Reports if a member was present on a date" do
|
69
69
|
date = Date.new(2000, 1, 1)
|
70
|
-
Osm::Register::Attendance.new(:attendance => {date => :yes}).present_on?(date).should
|
71
|
-
Osm::Register::Attendance.new(:attendance => {date => :known_absent}).present_on?(date).should
|
72
|
-
Osm::Register::Attendance.new(:attendance => {date => :unknown_absent}).present_on?(date).should
|
70
|
+
Osm::Register::Attendance.new(:attendance => {date => :yes}).present_on?(date).should == true
|
71
|
+
Osm::Register::Attendance.new(:attendance => {date => :known_absent}).present_on?(date).should == false
|
72
|
+
Osm::Register::Attendance.new(:attendance => {date => :unknown_absent}).present_on?(date).should == false
|
73
73
|
end
|
74
74
|
|
75
75
|
it "Reports if a member was absent on a date" do
|
76
76
|
date = Date.new(2000, 1, 1)
|
77
|
-
Osm::Register::Attendance.new(:attendance => {date => :yes}).absent_on?(date).should
|
78
|
-
Osm::Register::Attendance.new(:attendance => {date => :known_absent}).absent_on?(date).should
|
79
|
-
Osm::Register::Attendance.new(:attendance => {date => :unknown_absent}).absent_on?(date).should
|
77
|
+
Osm::Register::Attendance.new(:attendance => {date => :yes}).absent_on?(date).should == false
|
78
|
+
Osm::Register::Attendance.new(:attendance => {date => :known_absent}).absent_on?(date).should == true
|
79
|
+
Osm::Register::Attendance.new(:attendance => {date => :unknown_absent}).absent_on?(date).should == true
|
80
80
|
end
|
81
81
|
|
82
82
|
|
@@ -90,7 +90,7 @@ describe "Register" do
|
|
90
90
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure§ionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
|
91
91
|
|
92
92
|
register_structure = Osm::Register.get_structure(@api, 1, 2)
|
93
|
-
register_structure.is_a?(Array).should
|
93
|
+
register_structure.is_a?(Array).should == true
|
94
94
|
end
|
95
95
|
|
96
96
|
it "Fetch the register data for a section" do
|
@@ -117,7 +117,7 @@ describe "Register" do
|
|
117
117
|
] }
|
118
118
|
|
119
119
|
register = Osm::Register.get_attendance(@api, 1, 2)
|
120
|
-
register.is_a?(Array).should
|
120
|
+
register.is_a?(Array).should == true
|
121
121
|
register.size.should == 1
|
122
122
|
reg = register[0]
|
123
123
|
reg.attendance.should == {
|
@@ -131,7 +131,7 @@ describe "Register" do
|
|
131
131
|
reg.member_id.should == 2
|
132
132
|
reg.total.should == 4
|
133
133
|
reg.section_id.should == 1
|
134
|
-
reg.valid?.should
|
134
|
+
reg.valid?.should == true
|
135
135
|
end
|
136
136
|
|
137
137
|
it "Update register attendance" do
|
@@ -158,7 +158,7 @@ describe "Register" do
|
|
158
158
|
:attendance => :yes,
|
159
159
|
:members => 3,
|
160
160
|
:completed_badge_requirements => [{'a'=>'A'}, {'b'=>'B'}]
|
161
|
-
}).should
|
161
|
+
}).should == true
|
162
162
|
end
|
163
163
|
|
164
164
|
it "Handles the total row" do
|
@@ -186,7 +186,7 @@ describe "Register" do
|
|
186
186
|
Osm::Register.stub(:get_structure) { [] }
|
187
187
|
|
188
188
|
register = Osm::Register.get_attendance(@api, 1, 2)
|
189
|
-
register.is_a?(Array).should
|
189
|
+
register.is_a?(Array).should == true
|
190
190
|
register.size.should == 1
|
191
191
|
reg = register[0]
|
192
192
|
reg.first_name.should == 'First'
|
@@ -196,13 +196,13 @@ describe "Register" do
|
|
196
196
|
it "Handles no data getting structure" do
|
197
197
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=registerStructure§ionid=1&termid=2", :body => '', :content_type => 'application/json')
|
198
198
|
register_structure = Osm::Register.get_structure(@api, 1, 2)
|
199
|
-
register_structure.is_a?(Array).should
|
199
|
+
register_structure.is_a?(Array).should == true
|
200
200
|
register_structure.size.should == 0
|
201
201
|
|
202
202
|
|
203
203
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register§ionid=1&termid=2", :body => '', :content_type => 'application/json')
|
204
204
|
register = Osm::Register.get_attendance(@api, 1, 2)
|
205
|
-
register.is_a?(Array).should
|
205
|
+
register.is_a?(Array).should == true
|
206
206
|
register.size.should == 0
|
207
207
|
end
|
208
208
|
|
data/spec/osm/section_spec.rb
CHANGED
@@ -13,10 +13,6 @@ describe "Section" do
|
|
13
13
|
:subscription_expires => (Date.today + 60).strftime('%Y-%m-%d'),
|
14
14
|
:type => :cubs,
|
15
15
|
:wizard => false,
|
16
|
-
:column_names => {:column_names => 'names'},
|
17
|
-
:fields => {:fields => true},
|
18
|
-
:intouch_fields => {:intouch_fields => true},
|
19
|
-
:mobile_fields => {:mobile_fields => true},
|
20
16
|
:flexi_records => [],
|
21
17
|
:group_id => 3,
|
22
18
|
:group_name => '3rd Somewhere',
|
@@ -57,39 +53,35 @@ describe "Section" do
|
|
57
53
|
section.subscription_level.should == 2
|
58
54
|
section.subscription_expires.should == Date.today + 60
|
59
55
|
section.type.should == :cubs
|
60
|
-
section.column_names.should == {:column_names => 'names'}
|
61
|
-
section.fields.should == {:fields => true}
|
62
|
-
section.intouch_fields.should == {:intouch_fields => true}
|
63
|
-
section.mobile_fields.should == {:mobile_fields => true}
|
64
56
|
section.group_id.should == 3
|
65
57
|
section.group_name.should == '3rd Somewhere'
|
66
58
|
section.flexi_records.should == []
|
67
|
-
section.gocardless.should
|
59
|
+
section.gocardless.should == true
|
68
60
|
section.myscout_events_expires.should == Date.today + 61
|
69
61
|
section.myscout_badges_expires.should == Date.today + 62
|
70
62
|
section.myscout_programme_expires.should == Date.today + 63
|
71
63
|
section.myscout_details_expires.should == Date.today + 64
|
72
|
-
section.myscout_events.should
|
73
|
-
section.myscout_badges.should
|
74
|
-
section.myscout_programme.should
|
75
|
-
section.myscout_payments.should
|
64
|
+
section.myscout_events.should == true
|
65
|
+
section.myscout_badges.should == true
|
66
|
+
section.myscout_programme.should == true
|
67
|
+
section.myscout_payments.should == true
|
76
68
|
section.myscout_emails.should == {:email1 => true, :email2 => false}
|
77
69
|
section.myscout_email_address_from.should == 'send_from@example.com'
|
78
70
|
section.myscout_email_address_copy.should == ''
|
79
|
-
section.myscout_badges_partial.should
|
80
|
-
section.myscout_programme_summary.should
|
81
|
-
section.myscout_programme_times.should
|
71
|
+
section.myscout_badges_partial.should == true
|
72
|
+
section.myscout_programme_summary.should == true
|
73
|
+
section.myscout_programme_times.should == true
|
82
74
|
section.myscout_programme_show.should == 20
|
83
75
|
section.myscout_event_reminder_count.should == 4
|
84
76
|
section.myscout_event_reminder_frequency.should == 5
|
85
77
|
section.myscout_payment_reminder_count.should == 6
|
86
78
|
section.myscout_payment_reminder_frequency.should == 7
|
87
|
-
section.myscout_details.should
|
79
|
+
section.myscout_details.should == true
|
88
80
|
section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
|
89
|
-
section.sms_sent_test.should
|
81
|
+
section.sms_sent_test.should == true
|
90
82
|
section.sms_messages_sent.should == 8
|
91
83
|
section.sms_messages_remaining.should == 9
|
92
|
-
section.valid?.should
|
84
|
+
section.valid?.should == true
|
93
85
|
end
|
94
86
|
|
95
87
|
|
@@ -99,16 +91,12 @@ describe "Section" do
|
|
99
91
|
section.subscription_level.should == 1
|
100
92
|
section.subscription_expires.should be_nil
|
101
93
|
section.type.should == :unknown
|
102
|
-
section.column_names.should == {}
|
103
|
-
section.fields.should == {}
|
104
|
-
section.intouch_fields.should == {}
|
105
|
-
section.mobile_fields.should == {}
|
106
94
|
section.flexi_records.should == []
|
107
95
|
section.myscout_email_address_from.should == ''
|
108
96
|
section.myscout_email_address_copy.should == ''
|
109
97
|
section.myscout_details_email_changes_to.should == ''
|
110
98
|
section.myscout_programme_show.should == 0
|
111
|
-
section.sms_sent_test.should
|
99
|
+
section.sms_sent_test.should == false
|
112
100
|
section.sms_messages_sent.should == 0
|
113
101
|
section.sms_messages_remaining.should == 0
|
114
102
|
end
|
@@ -135,41 +123,37 @@ describe "Section" do
|
|
135
123
|
section.subscription_level.should == 1
|
136
124
|
section.subscription_expires.should == Date.new(2013, 1, 5)
|
137
125
|
section.type.should == :beavers
|
138
|
-
section.column_names.should == {:column_names => 'names'}
|
139
|
-
section.fields.should == {:fields => true}
|
140
|
-
section.intouch_fields.should == {:intouch_fields => true}
|
141
|
-
section.mobile_fields.should == {:mobile_fields => true}
|
142
126
|
section.group_id.should == 3
|
143
127
|
section.group_name.should == '3rd Somewhere'
|
144
128
|
section.flexi_records.size.should == 1
|
145
129
|
section.flexi_records[0].id.should == 111
|
146
130
|
section.flexi_records[0].name.should == 'Flexi Record 1'
|
147
|
-
section.gocardless.should
|
131
|
+
section.gocardless.should == true
|
148
132
|
section.myscout_events_expires.should == Date.new(2013, 1, 6)
|
149
133
|
section.myscout_badges_expires.should == Date.new(2013, 1, 7)
|
150
134
|
section.myscout_programme_expires.should == Date.new(2013, 1, 8)
|
151
135
|
section.myscout_programme_show.should == 10
|
152
136
|
section.myscout_details_expires.should == Date.new(2013, 1, 9)
|
153
|
-
section.myscout_events.should
|
154
|
-
section.myscout_badges.should
|
155
|
-
section.myscout_programme.should
|
156
|
-
section.myscout_payments.should
|
137
|
+
section.myscout_events.should == true
|
138
|
+
section.myscout_badges.should == true
|
139
|
+
section.myscout_programme.should == true
|
140
|
+
section.myscout_payments.should == true
|
157
141
|
section.myscout_emails.should == {:email1 => true, :email2 => false}
|
158
142
|
section.myscout_email_address_from.should == 'send_from@example.com'
|
159
143
|
section.myscout_email_address_copy.should == ''
|
160
|
-
section.myscout_badges_partial.should
|
161
|
-
section.myscout_programme_summary.should
|
162
|
-
section.myscout_programme_times.should
|
144
|
+
section.myscout_badges_partial.should == true
|
145
|
+
section.myscout_programme_summary.should == true
|
146
|
+
section.myscout_programme_times.should == true
|
163
147
|
section.myscout_event_reminder_count.should == 4
|
164
148
|
section.myscout_event_reminder_frequency.should == 5
|
165
149
|
section.myscout_payment_reminder_count.should == 6
|
166
150
|
section.myscout_payment_reminder_frequency.should == 7
|
167
|
-
section.myscout_details.should
|
151
|
+
section.myscout_details.should == true
|
168
152
|
section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
|
169
|
-
section.sms_sent_test.should
|
153
|
+
section.sms_sent_test.should == true
|
170
154
|
section.sms_messages_remaining.should == 8
|
171
155
|
section.sms_messages_sent.should == 9
|
172
|
-
section.valid?.should
|
156
|
+
section.valid?.should == true
|
173
157
|
end
|
174
158
|
|
175
159
|
it "From cache" do
|
@@ -183,7 +167,7 @@ describe "Section" do
|
|
183
167
|
section = Osm::Section.get(@api, 1)
|
184
168
|
section.should_not be_nil
|
185
169
|
section.id.should == 1
|
186
|
-
section.valid?.should
|
170
|
+
section.valid?.should == true
|
187
171
|
end
|
188
172
|
|
189
173
|
|
@@ -211,13 +195,13 @@ describe "Section" do
|
|
211
195
|
}
|
212
196
|
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true}'}) }
|
213
197
|
section = Osm::Section.new(:id => 1)
|
214
|
-
section.set_notepad(@api, 'content').should
|
198
|
+
section.set_notepad(@api, 'content').should == true
|
215
199
|
end
|
216
200
|
|
217
201
|
it "Sets the section's notepad (fail)" do
|
218
202
|
HTTParty.should_receive(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":false}'}) }
|
219
203
|
section = Osm::Section.new(:id => 1)
|
220
|
-
section.set_notepad(@api, 'content').should
|
204
|
+
section.set_notepad(@api, 'content').should == false
|
221
205
|
end
|
222
206
|
|
223
207
|
end
|
@@ -285,12 +269,12 @@ describe "Section" do
|
|
285
269
|
|
286
270
|
[beavers, cubs, scouts, explorers].each do |section|
|
287
271
|
it "For a #{section.type} section" do
|
288
|
-
section.youth_section?.should
|
272
|
+
section.youth_section?.should == true
|
289
273
|
end
|
290
274
|
end
|
291
275
|
[network, adults, waiting, unknown].each do |section|
|
292
276
|
it "For a #{section.type} section" do
|
293
|
-
section.youth_section?.should
|
277
|
+
section.youth_section?.should == false
|
294
278
|
end
|
295
279
|
end
|
296
280
|
end
|
@@ -429,33 +413,6 @@ describe "Online Scout Manager API Strangeness" do
|
|
429
413
|
sections[0].should_not be_nil
|
430
414
|
end
|
431
415
|
|
432
|
-
it "handles a section config where fields is an empty array" do
|
433
|
-
body = '[{"sectionConfig":"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member\'s Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member\'s Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Subs\",\"extraid\":\"529\"}],\"wizard\":\"false\",\"fields\":[],\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}","groupname":"1st Somewhere","groupid":"1","groupNormalised":"1","sectionid":"1","sectionname":"Section 1","section":"cubs","isDefault":"1","permissions":{"badge":100,"member":100,"user":100,"register":100,"contact":100,"programme":100,"originator":1,"events":100,"finance":100,"flexi":100}}]'
|
434
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body, :content_type => 'application/json')
|
435
|
-
|
436
|
-
sections = Osm::Section.get_all(@api)
|
437
|
-
sections.size.should == 1
|
438
|
-
section = sections[0]
|
439
|
-
section.should_not be_nil
|
440
|
-
section.fields.should == {}
|
441
|
-
end
|
442
|
-
|
443
|
-
it "handles a section's flexi records being a hash" do
|
444
|
-
body = [
|
445
|
-
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":{\"1\":{\"name\":\"Flexi Record 1\",\"extraid\":\"1\"},\"2\":{\"name\":\"Flexi Record 2\",\"extraid\":\"2\"}},\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
446
|
-
]
|
447
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
|
448
|
-
|
449
|
-
sections = Osm::Section.get_all(@api)
|
450
|
-
sections.size.should == 1
|
451
|
-
section = sections[0]
|
452
|
-
section.should_not be_nil
|
453
|
-
section.flexi_records.size.should == 2
|
454
|
-
fr = section.flexi_records[0]
|
455
|
-
fr.id.should == 1
|
456
|
-
fr.name.should == 'Flexi Record 1'
|
457
|
-
end
|
458
|
-
|
459
416
|
it "handles an empty array representing no notepads" do
|
460
417
|
body = [{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}]
|
461
418
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json, :content_type => 'application/json')
|