osm 0.1.12 → 0.1.13
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.
- data/CHANGELOG.md +10 -0
- data/README.md +3 -3
- data/lib/osm/activity.rb +38 -10
- data/lib/osm/event.rb +21 -2
- data/lib/osm/member.rb +5 -1
- data/lib/osm/section.rb +16 -1
- data/spec/osm/activity_spec.rb +81 -23
- data/spec/osm/event_spec.rb +25 -2
- data/spec/osm/member_spec.rb +2 -0
- data/spec/osm/section_spec.rb +31 -3
- data/version.rb +1 -1
- metadata +16 -16
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## Version 0.1.13
|
2
|
+
|
3
|
+
* Add attendance limit attributes to Event:
|
4
|
+
* attendance\_limit - Fixnum, 0 = no limit
|
5
|
+
* attendance\_limit\_includes\_leaders Boolean
|
6
|
+
* Add limited\_attendance? method to Event
|
7
|
+
* Add setting of a section's notepad
|
8
|
+
* Add updating of Activity
|
9
|
+
* Add grouping\_name attribute to Member
|
10
|
+
|
1
11
|
## Version 0.1.12
|
2
12
|
|
3
13
|
* Attribute Section.myscout\_email\_address\_send defaults to an empty String
|
data/README.md
CHANGED
@@ -100,6 +100,7 @@ however it should be noted that when the OSM API adds a feature it can be diffic
|
|
100
100
|
* Terms
|
101
101
|
|
102
102
|
### Update
|
103
|
+
* Activity
|
103
104
|
* Evening
|
104
105
|
* Event
|
105
106
|
* Event Attendance
|
@@ -133,10 +134,9 @@ however it should be noted that when the OSM API adds a feature it can be diffic
|
|
133
134
|
* Retreive [issue 21]
|
134
135
|
* Update [issue 22]
|
135
136
|
* Retrieve details for each badge (stock, short column names etc.) [issue 20]
|
136
|
-
* Update Activity
|
137
|
-
* Gift aid (Everything)
|
138
|
-
* Finances (Everything)
|
139
137
|
* SMS:
|
140
138
|
* Retreival of delivery reports
|
141
139
|
* Sending a message
|
140
|
+
* Gift aid (Everything)
|
141
|
+
* Finances (Everything)
|
142
142
|
* MyScout (Everything) (Maybe)
|
data/lib/osm/activity.rb
CHANGED
@@ -58,8 +58,8 @@ module Osm
|
|
58
58
|
attribute :location
|
59
59
|
attribute :shared, :type => Integer
|
60
60
|
attribute :rating, :type => Integer
|
61
|
-
attribute :editable, :type => Boolean
|
62
|
-
attribute :deletable, :type => Boolean
|
61
|
+
attribute :editable, :type => Boolean, :default => true
|
62
|
+
attribute :deletable, :type => Boolean, :default => true
|
63
63
|
attribute :used, :type => Integer
|
64
64
|
attribute :versions, :default => []
|
65
65
|
attribute :sections, :default => []
|
@@ -72,13 +72,13 @@ module Osm
|
|
72
72
|
:sections, :tags, :files, :badges
|
73
73
|
|
74
74
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0
|
75
|
-
validates_numericality_of :version, :only_integer=>true, :greater_than_or_equal_to=>0
|
76
|
-
validates_numericality_of :group_id, :only_integer=>true, :greater_than=>0
|
77
|
-
validates_numericality_of :user_id, :only_integer=>true, :greater_than=>0
|
75
|
+
validates_numericality_of :version, :only_integer=>true, :greater_than_or_equal_to=>0, :allow_nil=>true
|
76
|
+
validates_numericality_of :group_id, :only_integer=>true, :greater_than=>0, :allow_nil=>true
|
77
|
+
validates_numericality_of :user_id, :only_integer=>true, :greater_than=>0, :allow_nil=>true
|
78
78
|
validates_numericality_of :running_time, :only_integer=>true, :greater_than_or_equal_to=>0
|
79
|
-
validates_numericality_of :shared, :only_integer=>true, :greater_than_or_equal_to=>0
|
80
|
-
validates_numericality_of :rating, :only_integer=>true
|
81
|
-
validates_numericality_of :used, :only_integer=>true
|
79
|
+
validates_numericality_of :shared, :only_integer=>true, :greater_than_or_equal_to=>0, :allow_nil=>true
|
80
|
+
validates_numericality_of :rating, :only_integer=>true, :allow_nil=>true
|
81
|
+
validates_numericality_of :used, :only_integer=>true, :allow_nil=>true
|
82
82
|
validates_presence_of :title
|
83
83
|
validates_presence_of :description
|
84
84
|
validates_presence_of :resources
|
@@ -179,10 +179,10 @@ module Osm
|
|
179
179
|
|
180
180
|
# Add this activity to the programme in OSM
|
181
181
|
# @param [Osm::Api] api The api to use to make the request
|
182
|
-
# @param [Osm::Section, Fixnum]
|
182
|
+
# @param [Osm::Section, Fixnum] section The Section (or it's ID) to add the Activity to
|
183
183
|
# @param [Date, DateTime] date The date of the Evening to add the Activity to (OSM will create the Evening if it doesn't already exist)
|
184
184
|
# @param [String] notes The notes which should appear for this Activity on this Evening
|
185
|
-
# @return [Boolean] Whether the activity
|
185
|
+
# @return [Boolean] Whether the activity was successfully added
|
186
186
|
def add_to_programme(api, section, date, notes="")
|
187
187
|
data = api.perform_query("programme.php?action=addActivityToProgramme", {
|
188
188
|
'meetingdate' => date.strftime(Osm::OSM_DATE_FORMAT),
|
@@ -194,6 +194,34 @@ module Osm
|
|
194
194
|
return (data == {'result'=>0})
|
195
195
|
end
|
196
196
|
|
197
|
+
# Update this activity in OSM
|
198
|
+
# @param [Osm::Api] api The api to use to make the request
|
199
|
+
# @param [Osm::Section, Fixnum] section The Section (or it's ID)
|
200
|
+
# @param [Boolean] secret_update Whether this is a secret update
|
201
|
+
# @return [Boolean] Whether the activity was successfully added
|
202
|
+
def update(api, section, secret_update=false)
|
203
|
+
raise ObjectIsInvalid, 'activity is invalid' unless valid?
|
204
|
+
|
205
|
+
data = api.perform_query("programme.php?action=update", {
|
206
|
+
'title' => title,
|
207
|
+
'description' => description,
|
208
|
+
'resources' => resources,
|
209
|
+
'instructions' => instructions,
|
210
|
+
'id' => id,
|
211
|
+
'files' => files.map{|f| f.id }.join(','),
|
212
|
+
'time' => running_time.to_s,
|
213
|
+
'location' => location,
|
214
|
+
'sections' => sections.to_json,
|
215
|
+
'tags' => tags.to_json,
|
216
|
+
'links' => badges.map{ |b| {'activityid'=>b.activity_id.to_s, 'section'=>b.section_type, 'badgetype'=>b.type, 'badge'=>b.badge, 'columnname'=>b.requirement, 'label'=>b.label}}.to_json,
|
217
|
+
'shared' => shared,
|
218
|
+
'sectionid' => section.to_i,
|
219
|
+
'secretEdit' => secret_update,
|
220
|
+
})
|
221
|
+
|
222
|
+
return (data == {'result'=>true})
|
223
|
+
end
|
224
|
+
|
197
225
|
|
198
226
|
private
|
199
227
|
class File
|
data/lib/osm/event.rb
CHANGED
@@ -36,6 +36,10 @@ module Osm
|
|
36
36
|
# @return [Boolean] whether parent's can change their child's details
|
37
37
|
# @!attribute [rw] reminders
|
38
38
|
# @return [Boolean] whether email reminders are sent for the event
|
39
|
+
# @!attribute [rw] attendance_limit
|
40
|
+
# @return [Fixnum] the maximum number of people who can attend the event (0 = no limit)
|
41
|
+
# @!attendance [rw] attendance_limit_includes_leaders
|
42
|
+
# @return [Boolean] whether the attendance limit includes leaders
|
39
43
|
|
40
44
|
attribute :id, :type => Integer
|
41
45
|
attribute :section_id, :type => Integer
|
@@ -52,17 +56,21 @@ module Osm
|
|
52
56
|
attribute :confirm_by_date, :type => Date
|
53
57
|
attribute :allow_changes, :type => Boolean, :default => false
|
54
58
|
attribute :reminders, :type => Boolean, :default => true
|
59
|
+
attribute :attendance_limit, :type => Integer, :default => 0
|
60
|
+
attribute :attendance_limit_includes_leaders, :type => Boolean, :default => false
|
55
61
|
|
56
62
|
attr_accessible :id, :section_id, :name, :start, :finish, :cost, :location, :notes, :archived,
|
57
|
-
:fields, :columns, :notepad, :public_notepad,
|
58
|
-
:
|
63
|
+
:fields, :columns, :notepad, :public_notepad, :confirm_by_date, :allow_changes,
|
64
|
+
:reminders, :attendance_limit, :attendance_limit_includes_leaders
|
59
65
|
|
60
66
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0, :allow_nil => true
|
61
67
|
validates_numericality_of :section_id, :only_integer=>true, :greater_than=>0
|
68
|
+
validates_numericality_of :attendance_limit, :only_integer=>true, :greater_than_or_equal_to=>0
|
62
69
|
validates_presence_of :name
|
63
70
|
validates :columns, :array_of => {:item_type => Osm::Event::Column, :item_valid => true}
|
64
71
|
validates_inclusion_of :allow_changes, :in => [true, false]
|
65
72
|
validates_inclusion_of :reminders, :in => [true, false]
|
73
|
+
validates_inclusion_of :attendance_limit_includes_leaders, :in => [true, false]
|
66
74
|
|
67
75
|
|
68
76
|
# @!method initialize
|
@@ -144,6 +152,8 @@ module Osm
|
|
144
152
|
'confdate' => event.confirm_by_date? ? event.confirm_by_date.strftime(Osm::OSM_DATE_FORMAT) : '',
|
145
153
|
'allowChanges' => event.allow_changes ? 'true' : 'false',
|
146
154
|
'disablereminders' => !event.reminders ? 'true' : 'false',
|
155
|
+
'attendancelimit' => event.attendance_limit,
|
156
|
+
'limitincludesleaders' => event.attendance_limit_includes_leaders,
|
147
157
|
})
|
148
158
|
|
149
159
|
# The cached events for the section will be out of date - remove them
|
@@ -177,6 +187,8 @@ module Osm
|
|
177
187
|
'confdate' => confirm_by_date? ? confirm_by_date.strftime(Osm::OSM_DATE_FORMAT) : '',
|
178
188
|
'allowChanges' => allow_changes ? 'true' : 'false',
|
179
189
|
'disablereminders' => !reminders ? 'true' : 'false',
|
190
|
+
'attendancelimit' => attendance_limit,
|
191
|
+
'limitincludesleaders' => attendance_limit_includes_leaders,
|
180
192
|
})
|
181
193
|
api.perform_query("events.php?action=saveNotepad§ionid=#{section_id}", {
|
182
194
|
'eventid' => id,
|
@@ -309,6 +321,11 @@ module Osm
|
|
309
321
|
end
|
310
322
|
|
311
323
|
|
324
|
+
def limited_attendance?
|
325
|
+
(attendance_limit != 0)
|
326
|
+
end
|
327
|
+
|
328
|
+
|
312
329
|
private
|
313
330
|
def self.new_event_from_data(event_data)
|
314
331
|
event = Osm::Event.new(
|
@@ -326,6 +343,8 @@ module Osm
|
|
326
343
|
:confirm_by_date => Osm::parse_date(event_data['confdate']),
|
327
344
|
:allow_changes => event_data['allowchanges'].eql?('1'),
|
328
345
|
:reminders => !event_data['disablereminders'].eql?('1'),
|
346
|
+
:attendance_limit => event_data['attendancelimit'].to_i,
|
347
|
+
:attendance_limit_includes_leaders => event_data['limitincludesleaders'].eql?('1'),
|
329
348
|
)
|
330
349
|
|
331
350
|
columns = []
|
data/lib/osm/member.rb
CHANGED
@@ -74,6 +74,8 @@ module Osm
|
|
74
74
|
# @return [Fixnum] the grouping within the section that the member belongs to
|
75
75
|
# @!attribute [rw] grouping_leader
|
76
76
|
# @return [Fixnum] whether the member is the grouping leader (0=no, 1=seconder/APL, 2=sixer/PL)
|
77
|
+
# @!attribute [rw] grouping_name
|
78
|
+
# @return [Fixnum] the grouping within the section that the member belongs to
|
77
79
|
# @!attribute [rw] joined
|
78
80
|
# @return [Date] when the member joined the section
|
79
81
|
# @!attribute [rw] age
|
@@ -116,6 +118,7 @@ module Osm
|
|
116
118
|
attribute :custom8, :type => String, :default => ''
|
117
119
|
attribute :custom9, :type => String, :default => ''
|
118
120
|
attribute :grouping_id, :type => Integer
|
121
|
+
attribute :grouping_name, :type => String, :default => ''
|
119
122
|
attribute :grouping_leader, :type => Integer
|
120
123
|
attribute :joined, :type => Date
|
121
124
|
attribute :age, :type => String
|
@@ -125,7 +128,7 @@ module Osm
|
|
125
128
|
:phone1, :phone2, :phone3, :phone4, :address, :address2, :date_of_birth, :started,
|
126
129
|
:joining_in_years, :parents, :notes, :medical, :religion, :school, :ethnicity, :subs,
|
127
130
|
:custom1, :custom2, :custom3, :custom4, :custom5, :custom6, :custom7, :custom8, :custom9,
|
128
|
-
:grouping_id, :grouping_leader, :joined, :age, :joined_years
|
131
|
+
:grouping_id, :grouping_name, :grouping_leader, :joined, :age, :joined_years
|
129
132
|
|
130
133
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0, :unless => Proc.new { |r| r.id.nil? }
|
131
134
|
validates_numericality_of :section_id, :only_integer=>true, :greater_than=>0
|
@@ -197,6 +200,7 @@ module Osm
|
|
197
200
|
:custom8 => item['custom8'],
|
198
201
|
:custom9 => item['custom9'],
|
199
202
|
:grouping_id => Osm::to_i_or_nil(item['patrolid']),
|
203
|
+
:grouping_name => Osm::to_i_or_nil(item['patrol']),
|
200
204
|
:grouping_leader => Osm::to_i_or_nil(item['patrolleader']),
|
201
205
|
:joined => Osm::parse_date(item['joined']),
|
202
206
|
:age => item['age'].gsub(' ', ''),
|
data/lib/osm/section.rb
CHANGED
@@ -275,7 +275,7 @@ module Osm
|
|
275
275
|
end
|
276
276
|
|
277
277
|
|
278
|
-
# Get the section's
|
278
|
+
# Get the section's notepad from OSM
|
279
279
|
# @param [Osm::Api] The api to use to make the request
|
280
280
|
# @!macro options_get
|
281
281
|
# @return [String] the section's notepad
|
@@ -298,6 +298,21 @@ module Osm
|
|
298
298
|
return notepad
|
299
299
|
end
|
300
300
|
|
301
|
+
# Set the section's notepad in OSM
|
302
|
+
# @param [Osm::Api] api The api to use to make the request
|
303
|
+
# @param [String] content The content of the notepad
|
304
|
+
# @return [Boolean] whether the notepad was sucessfully updated
|
305
|
+
def set_notepad(api, content)
|
306
|
+
data = api.perform_query("users.php?action=updateNotepad§ionid=#{id}", {'value' => content})
|
307
|
+
|
308
|
+
if data.is_a?(Hash) && data['ok'] # Success
|
309
|
+
cache_write(api, ['notepad', id], content)
|
310
|
+
return true
|
311
|
+
end
|
312
|
+
return false
|
313
|
+
end
|
314
|
+
|
315
|
+
|
301
316
|
# Get badge stock levels
|
302
317
|
# @param [Osm::Api] The api to use to make the request
|
303
318
|
# @param [Osm::Term, Fixnum, nil] section the term (or its ID) to get the stock levels for, passing nil causes the current term to be used
|
data/spec/osm/activity_spec.rb
CHANGED
@@ -94,28 +94,86 @@ describe "Using The API" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
97
|
+
it "Add activity to programme (succeded)" do
|
98
|
+
url = 'https://www.onlinescoutmanager.co.uk/programme.php?action=addActivityToProgramme'
|
99
|
+
post_data = {
|
100
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
101
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
102
|
+
'userid' => 'user_id',
|
103
|
+
'secret' => 'secret',
|
104
|
+
'meetingdate' => '2000-01-02',
|
105
|
+
'sectionid' => 1,
|
106
|
+
'activityid' => 2,
|
107
|
+
'notes' => 'Notes',
|
108
|
+
}
|
109
|
+
|
110
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":0}'}) }
|
111
|
+
activity = Osm::Activity.new(:id => 2)
|
112
|
+
activity.add_to_programme(@api, 1, Date.new(2000, 1, 2), 'Notes').should be_true
|
113
|
+
end
|
114
|
+
|
115
|
+
it "Add activity to programme (failed)" do
|
116
|
+
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
|
117
|
+
activity = Osm::Activity.new(:id => 2)
|
118
|
+
activity.add_to_programme(@api, 1, Date.new(2000, 1, 2), 'Notes').should be_false
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
it "Update activity in OSM (succeded)" do
|
123
|
+
url = 'https://www.onlinescoutmanager.co.uk/programme.php?action=update'
|
124
|
+
post_data = {
|
125
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
126
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
127
|
+
'userid' => 'user_id',
|
128
|
+
'secret' => 'secret',
|
129
|
+
'title' => 'title',
|
130
|
+
'description' => 'description',
|
131
|
+
'resources' => 'resources',
|
132
|
+
'instructions' => 'instructions',
|
133
|
+
'id' => 2,
|
134
|
+
'files' => '3,4',
|
135
|
+
'time' => '5',
|
136
|
+
'location' => :indoors,
|
137
|
+
'sections' => '["beavers","cubs"]',
|
138
|
+
'tags' => '["tag1","tag2"]',
|
139
|
+
'links' => '[{"activityid":"2","section":"beavers","badgetype":"t","badge":"b","columnname":"r","label":"l"}]',
|
140
|
+
'shared' => 0,
|
141
|
+
'sectionid' => 1,
|
142
|
+
'secretEdit' => true,
|
143
|
+
}
|
144
|
+
|
145
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":true}'}) }
|
146
|
+
activity = Osm::Activity.new(
|
147
|
+
:id => 2,
|
148
|
+
:title => 'title',
|
149
|
+
:description => 'description',
|
150
|
+
:resources => 'resources',
|
151
|
+
:instructions => 'instructions',
|
152
|
+
:files => [Osm::Activity::File.new(:id=>3, :activity_id=>2, :file_name=>'fn', :name=>'n'), Osm::Activity::File.new(:id=>4, :activity_id=>2, :file_name=>'fn2', :name=>'n2')],
|
153
|
+
:running_time => 5,
|
154
|
+
:location => :indoors,
|
155
|
+
:sections => [:beavers, :cubs],
|
156
|
+
:tags => ['tag1', 'tag2'],
|
157
|
+
:badges => [Osm::Activity::Badge.new(:activity_id=>2, :section_type=>:beavers, :type=>:t, :badge=>'b', :requirement=>'r', :label=>'l')],
|
158
|
+
:shared => 0,
|
159
|
+
:section_id => 1,
|
160
|
+
)
|
161
|
+
activity.update(@api, 1, true).should be_true
|
162
|
+
end
|
163
|
+
|
164
|
+
it "Update activity in OSM (failed)" do
|
165
|
+
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":false}'}) }
|
166
|
+
activity = Osm::Activity.new(
|
167
|
+
:id => 2,
|
168
|
+
:title => 'title',
|
169
|
+
:description => 'description',
|
170
|
+
:resources => 'resources',
|
171
|
+
:instructions => 'instructions',
|
172
|
+
:location => :indoors,
|
173
|
+
:running_time => 0,
|
174
|
+
)
|
175
|
+
activity.update(@api, 1, true).should be_false
|
176
|
+
end
|
177
|
+
|
120
178
|
|
121
179
|
end
|
data/spec/osm/event_spec.rb
CHANGED
@@ -21,6 +21,8 @@ describe "Event" do
|
|
21
21
|
:confirm_by_date => Date.new(2002, 1, 2),
|
22
22
|
:allow_changes => true,
|
23
23
|
:reminders => false,
|
24
|
+
:attendance_limit => 3,
|
25
|
+
:attendance_limit_includes_leaders => true,
|
24
26
|
}
|
25
27
|
event = Osm::Event.new(data)
|
26
28
|
|
@@ -39,9 +41,16 @@ describe "Event" do
|
|
39
41
|
event.confirm_by_date.should == Date.new(2002, 1, 2)
|
40
42
|
event.allow_changes.should == true
|
41
43
|
event.reminders.should == false
|
44
|
+
event.attendance_limit.should == 3
|
45
|
+
event.attendance_limit_includes_leaders.should == true
|
42
46
|
event.valid?.should be_true
|
43
47
|
end
|
44
48
|
|
49
|
+
it "Correctly tells if attendance is limited" do
|
50
|
+
Osm::Event.new(:attendance_limit => 0).limited_attendance?.should be_false
|
51
|
+
Osm::Event.new(:attendance_limit => 1).limited_attendance?.should be_true
|
52
|
+
end
|
53
|
+
|
45
54
|
it "Create Event::Attendance" do
|
46
55
|
data = {
|
47
56
|
:member_id => 1,
|
@@ -81,7 +90,9 @@ describe "Event" do
|
|
81
90
|
'archived' => '0',
|
82
91
|
'confdate' => nil,
|
83
92
|
'allowchanges' => '1',
|
84
|
-
'disablereminders' => '1'
|
93
|
+
'disablereminders' => '1',
|
94
|
+
'attendancelimit' => '3',
|
95
|
+
'limitincludesleaders' => '1',
|
85
96
|
}]
|
86
97
|
}
|
87
98
|
|
@@ -105,7 +116,9 @@ describe "Event" do
|
|
105
116
|
'allowchanges' => '1',
|
106
117
|
'disablereminders' => '1',
|
107
118
|
'pnnotepad' => '',
|
108
|
-
'structure' => []
|
119
|
+
'structure' => [],
|
120
|
+
'attendancelimit' => '3',
|
121
|
+
'limitincludesleaders' => '1',
|
109
122
|
}
|
110
123
|
|
111
124
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents§ionid=1&showArchived=true", :body => events_body.to_json)
|
@@ -132,6 +145,8 @@ describe "Event" do
|
|
132
145
|
event.confirm_by_date.should == Date.new(2002, 1, 2)
|
133
146
|
event.allow_changes.should == true
|
134
147
|
event.reminders.should == false
|
148
|
+
event.attendance_limit.should == 3
|
149
|
+
event.attendance_limit_includes_leaders.should == true
|
135
150
|
event.columns[0].id.should == 'f_1'
|
136
151
|
event.columns[0].name.should == 'Name'
|
137
152
|
event.columns[0].label.should == 'Label'
|
@@ -208,6 +223,8 @@ describe "Event" do
|
|
208
223
|
'confdate' => '2000-01-01',
|
209
224
|
'allowChanges' => 'true',
|
210
225
|
'disablereminders' => 'false',
|
226
|
+
'attendancelimit' => 3,
|
227
|
+
'limitincludesleaders' => true,
|
211
228
|
}
|
212
229
|
|
213
230
|
Osm::Event.stub(:get_for_section) { [] }
|
@@ -227,6 +244,8 @@ describe "Event" do
|
|
227
244
|
:confirm_by_date => Date.new(2000, 1, 1),
|
228
245
|
:allow_changes => true,
|
229
246
|
:reminders => true,
|
247
|
+
:attendance_limit => 3,
|
248
|
+
:attendance_limit_includes_leaders => true,
|
230
249
|
})
|
231
250
|
event.should_not be_nil
|
232
251
|
event.id.should == 2
|
@@ -274,6 +293,8 @@ describe "Event" do
|
|
274
293
|
'confdate' => '',
|
275
294
|
'allowChanges' => 'true',
|
276
295
|
'disablereminders' => 'false',
|
296
|
+
'attendancelimit' => 3,
|
297
|
+
'limitincludesleaders' => true,
|
277
298
|
}
|
278
299
|
|
279
300
|
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"id":2}'}) }
|
@@ -294,6 +315,8 @@ describe "Event" do
|
|
294
315
|
:reminders => true,
|
295
316
|
:notepad => 'notepad',
|
296
317
|
:public_notepad => 'public notepad',
|
318
|
+
:attendance_limit => 3,
|
319
|
+
:attendance_limit_includes_leaders => true,
|
297
320
|
)
|
298
321
|
event.update(@api).should be_true
|
299
322
|
end
|
data/spec/osm/member_spec.rb
CHANGED
@@ -41,6 +41,7 @@ describe "Member" do
|
|
41
41
|
:custom9 => 'Custom Field 9',
|
42
42
|
:grouping_id => '3',
|
43
43
|
:grouping_leader => 0,
|
44
|
+
:grouping_name => 'Grouping',
|
44
45
|
:joined => '2006-01-07',
|
45
46
|
:age => '06/07',
|
46
47
|
:joined_years => 1,
|
@@ -82,6 +83,7 @@ describe "Member" do
|
|
82
83
|
member.custom8.should == 'Custom Field 8'
|
83
84
|
member.custom9.should == 'Custom Field 9'
|
84
85
|
member.grouping_id.should == 3
|
86
|
+
member.grouping_name.should == 'Grouping'
|
85
87
|
member.grouping_leader.should == 0
|
86
88
|
member.joined.should == Date.new(2006, 1, 7)
|
87
89
|
member.age.should == '06/07'
|
data/spec/osm/section_spec.rb
CHANGED
@@ -165,13 +165,41 @@ describe "Section" do
|
|
165
165
|
}
|
166
166
|
end
|
167
167
|
|
168
|
+
|
168
169
|
it "Gets the section's notepad" do
|
169
|
-
|
170
|
-
|
171
|
-
|
170
|
+
url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getNotepads'
|
171
|
+
post_data = {
|
172
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
173
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
174
|
+
'userid' => 'user_id',
|
175
|
+
'secret' => 'secret',
|
176
|
+
}
|
177
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>{"1" => "Section 1", "2" => "Section 2"}.to_json}) }
|
178
|
+
section = Osm::Section.new(:id => 1)
|
172
179
|
section.get_notepad(@api).should == 'Section 1'
|
173
180
|
end
|
174
181
|
|
182
|
+
it "Sets the section's notepad (success)" do
|
183
|
+
url = 'https://www.onlinescoutmanager.co.uk/users.php?action=updateNotepad§ionid=1'
|
184
|
+
post_data = {
|
185
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
186
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
187
|
+
'userid' => 'user_id',
|
188
|
+
'secret' => 'secret',
|
189
|
+
'value' => 'content'
|
190
|
+
}
|
191
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true}'}) }
|
192
|
+
section = Osm::Section.new(:id => 1)
|
193
|
+
section.set_notepad(@api, 'content').should be_true
|
194
|
+
end
|
195
|
+
|
196
|
+
it "Sets the section's notepad (fail)" do
|
197
|
+
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":false}'}) }
|
198
|
+
section = Osm::Section.new(:id => 1)
|
199
|
+
section.set_notepad(@api, 'content').should be_false
|
200
|
+
end
|
201
|
+
|
202
|
+
|
175
203
|
it "Fetch badge stock levels" do
|
176
204
|
badges_body = {
|
177
205
|
'stock' => {
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &80640130 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *80640130
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &80639220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.9'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *80639220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: active_attr
|
38
|
-
requirement: &
|
38
|
+
requirement: &80638900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.6'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *80638900
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activemodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &80638500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.2'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *80638500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &80638080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '10.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *80638080
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &80637470 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.11'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *80637470
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: fakeweb
|
82
|
-
requirement: &
|
82
|
+
requirement: &80637090 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '1.3'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *80637090
|
91
91
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
92
92
|
to retrieve and save data.
|
93
93
|
email:
|