osm 1.0.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -482,7 +482,7 @@ describe "Member" do
482
482
  end
483
483
 
484
484
  describe "Get My.SCOUT link" do
485
-
485
+
486
486
  before :each do
487
487
  @member = Osm::Member.new(
488
488
  :id => 1,
@@ -495,7 +495,9 @@ describe "Member" do
495
495
  :grouping_id => '3',
496
496
  :grouping_leader => 0,
497
497
  )
498
+ end
498
499
 
500
+ it "Get the key" do
499
501
  url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
500
502
  HTTParty.should_receive(:post).with(url, {:body => {
501
503
  'apiid' => @CONFIGURATION[:api][:osm][:id],
@@ -503,32 +505,50 @@ describe "Member" do
503
505
  'userid' => 'user_id',
504
506
  'secret' => 'secret',
505
507
  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true,"key":"KEY-HERE"}'}) }
508
+
509
+ @member.myscout_link_key(@api).should == 'KEY-HERE'
506
510
  end
507
511
 
508
512
  it "Default" do
513
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
509
514
  @member.myscout_link(@api).should == 'https://www.onlinescoutmanager.co.uk/parents/badges.php?sc=1&se=2&c=KEY-HERE'
510
515
  end
511
516
 
512
517
  it "Payments" do
518
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
513
519
  @member.myscout_link(@api, :payments).should == 'https://www.onlinescoutmanager.co.uk/parents/payments.php?sc=1&se=2&c=KEY-HERE'
514
520
  end
515
521
 
516
522
  it "Events" do
523
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
517
524
  @member.myscout_link(@api, :events).should == 'https://www.onlinescoutmanager.co.uk/parents/events.php?sc=1&se=2&c=KEY-HERE'
518
525
  end
519
526
 
527
+ it "Specific Event" do
528
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
529
+ @member.myscout_link(@api, :events, 2).should == 'https://www.onlinescoutmanager.co.uk/parents/events.php?sc=1&se=2&c=KEY-HERE&e=2'
530
+ end
531
+
520
532
  it "Programme" do
533
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
521
534
  @member.myscout_link(@api, :programme).should == 'https://www.onlinescoutmanager.co.uk/parents/programme.php?sc=1&se=2&c=KEY-HERE'
522
535
  end
523
536
 
524
537
  it "Badges" do
538
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
525
539
  @member.myscout_link(@api, :badges).should == 'https://www.onlinescoutmanager.co.uk/parents/badges.php?sc=1&se=2&c=KEY-HERE'
526
540
  end
527
541
 
528
542
  it "Notice board" do
543
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
529
544
  @member.myscout_link(@api, :notice).should == 'https://www.onlinescoutmanager.co.uk/parents/notice.php?sc=1&se=2&c=KEY-HERE'
530
545
  end
531
546
 
547
+ it "Personal details" do
548
+ @member.stub(:myscout_link_key) { 'KEY-HERE' }
549
+ @member.myscout_link(@api, :details).should == 'https://www.onlinescoutmanager.co.uk/parents/details.php?sc=1&se=2&c=KEY-HERE'
550
+ end
551
+
532
552
  end
533
553
 
534
554
  end
@@ -24,6 +24,7 @@ describe "Section" do
24
24
  :myscout_events_expires => (Date.today + 61).strftime('%Y-%m-%d'),
25
25
  :myscout_badges_expires => (Date.today + 62).strftime('%Y-%m-%d'),
26
26
  :myscout_programme_expires => (Date.today + 63).strftime('%Y-%m-%d'),
27
+ :myscout_details_expires => (Date.today + 64),
27
28
  :myscout_events => true,
28
29
  :myscout_badges => true,
29
30
  :myscout_programme => true,
@@ -34,10 +35,13 @@ describe "Section" do
34
35
  :myscout_badges_partial => true,
35
36
  :myscout_programme_summary => true,
36
37
  :myscout_programme_times => true,
38
+ :myscout_programme_show => 20,
37
39
  :myscout_event_reminder_count => 4,
38
40
  :myscout_event_reminder_frequency => 5,
39
41
  :myscout_payment_reminder_count => 6,
40
42
  :myscout_payment_reminder_frequency => 7,
43
+ :myscout_details => true,
44
+ :myscout_details_email_changes_to => 'notify-changes-to@example.com',
41
45
  :sms_sent_test => true,
42
46
  :sms_messages_sent => 8,
43
47
  :sms_messages_remaining => 9,
@@ -64,6 +68,7 @@ describe "Section" do
64
68
  section.myscout_events_expires.should == Date.today + 61
65
69
  section.myscout_badges_expires.should == Date.today + 62
66
70
  section.myscout_programme_expires.should == Date.today + 63
71
+ section.myscout_details_expires.should == Date.today + 64
67
72
  section.myscout_events.should == true
68
73
  section.myscout_badges.should == true
69
74
  section.myscout_programme.should == true
@@ -74,10 +79,13 @@ describe "Section" do
74
79
  section.myscout_badges_partial.should == true
75
80
  section.myscout_programme_summary.should == true
76
81
  section.myscout_programme_times.should == true
82
+ section.myscout_programme_show.should == 20
77
83
  section.myscout_event_reminder_count.should == 4
78
84
  section.myscout_event_reminder_frequency.should == 5
79
85
  section.myscout_payment_reminder_count.should == 6
80
86
  section.myscout_payment_reminder_frequency.should == 7
87
+ section.myscout_details.should == true
88
+ section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
81
89
  section.sms_sent_test.should == true
82
90
  section.sms_messages_sent.should == 8
83
91
  section.sms_messages_remaining.should == 9
@@ -98,6 +106,8 @@ describe "Section" do
98
106
  section.flexi_records.should == []
99
107
  section.myscout_email_address_from.should == ''
100
108
  section.myscout_email_address_copy.should == ''
109
+ section.myscout_details_email_changes_to.should == ''
110
+ section.myscout_programme_show.should == 0
101
111
  section.sms_sent_test.should == false
102
112
  section.sms_messages_sent.should == 0
103
113
  section.sms_messages_remaining.should == 0
@@ -108,7 +118,7 @@ describe "Section" do
108
118
 
109
119
  before :each do
110
120
  body = [
111
- {"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},\"gocardless\":\"true\",\"portal\":{\"paymentRemindFrequency\":\"7\",\"paymentRemindCount\":\"6\",\"eventRemindFrequency\":\"5\",\"eventRemindCount\":\"4\",\"badgesPartial\":1,\"programmeTimes\":1,\"programmeSummary\":1,\"emailAddress\":\"send_from@example.com\",\"emailAddressCopy\":null,\"payments\":1,\"badges\":1,\"emails\":{\"email1\":\"true\",\"email2\":\"false\"},\"events\":1,\"programme\":1},\"portalExpires\":{\"events\":\"2013-01-06\",\"eventsA\":1,\"badges\":\"2013-01-07\",\"badgesA\":1,\"programme\":\"2013-01-08\",\"programmeA\":1},\"hasSentTestSMS\":true,\"sms_remaining\":8,\"sms_sent\":9}", "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}},
121
+ {"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},\"gocardless\":\"true\",\"portal\":{\"paymentRemindFrequency\":\"7\",\"paymentRemindCount\":\"6\",\"eventRemindFrequency\":\"5\",\"eventRemindCount\":\"4\",\"badgesPartial\":1,\"programmeTimes\":1,\"programmeShow\":\"10\",\"programmeSummary\":1,\"details\":1,\"contactNotificationEmail\":\"notify-changes-to@example.com\",\"emailAddress\":\"send_from@example.com\",\"emailAddressCopy\":null,\"payments\":1,\"badges\":1,\"emails\":{\"email1\":\"true\",\"email2\":\"false\"},\"events\":1,\"programme\":1},\"portalExpires\":{\"events\":\"2013-01-06\",\"eventsA\":1,\"badges\":\"2013-01-07\",\"badgesA\":1,\"programme\":\"2013-01-08\",\"programmeA\":1,\"details\":\"2013-01-09\",\"detailsA\":1},\"hasSentTestSMS\":true,\"sms_remaining\":8,\"sms_sent\":9}", "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}},
112
122
  {"sectionConfig"=>"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"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\":[],\"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},\"hasSentTestSMS\":true,\"sms_remaining\":8,\"sms_sent\":9}", "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"2", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
113
123
  ]
114
124
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
@@ -138,6 +148,8 @@ describe "Section" do
138
148
  section.myscout_events_expires.should == Date.new(2013, 1, 6)
139
149
  section.myscout_badges_expires.should == Date.new(2013, 1, 7)
140
150
  section.myscout_programme_expires.should == Date.new(2013, 1, 8)
151
+ section.myscout_programme_show.should == 10
152
+ section.myscout_details_expires.should == Date.new(2013, 1, 9)
141
153
  section.myscout_events.should == true
142
154
  section.myscout_badges.should == true
143
155
  section.myscout_programme.should == true
@@ -152,9 +164,12 @@ describe "Section" do
152
164
  section.myscout_event_reminder_frequency.should == 5
153
165
  section.myscout_payment_reminder_count.should == 6
154
166
  section.myscout_payment_reminder_frequency.should == 7
167
+ section.myscout_details.should == true
168
+ section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
155
169
  section.sms_sent_test.should == true
156
170
  section.sms_messages_remaining.should == 8
157
171
  section.sms_messages_sent.should == 9
172
+ section.valid?.should be_true
158
173
  end
159
174
 
160
175
  it "From cache" do
data/spec/osm/sms_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe "SMS" do
5
5
 
6
6
  describe "Send an SMS" do
7
7
 
8
- it "Success" do
8
+ it "First" do
9
9
  HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/sms.php?action=sendText&sectionid=1', {:body => {
10
10
  'apiid' => @CONFIGURATION[:api][:osm][:id],
11
11
  'token' => @CONFIGURATION[:api][:osm][:token],
@@ -14,7 +14,7 @@ describe "SMS" do
14
14
  'msg' => 'Test message.',
15
15
  'scouts' => '2,3',
16
16
  'source' => '441234567890',
17
- 'all' => :one,
17
+ 'type' => :one,
18
18
  'scheduled' => 'now',
19
19
  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
20
20
 
@@ -22,7 +22,94 @@ describe "SMS" do
22
22
  @api,
23
23
  1, # Section
24
24
  [2, 3], # Members
25
- :one,
25
+ :first,
26
+ '441234567890', # Source address
27
+ 'Test message.' # Message text
28
+ )
29
+
30
+ result.should == {
31
+ :result => true,
32
+ :sent => 2,
33
+ :message => 'Success'
34
+ }
35
+ end
36
+
37
+ it "All" do
38
+ HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/sms.php?action=sendText&sectionid=1', {:body => {
39
+ 'apiid' => @CONFIGURATION[:api][:osm][:id],
40
+ 'token' => @CONFIGURATION[:api][:osm][:token],
41
+ 'userid' => 'user_id',
42
+ 'secret' => 'secret',
43
+ 'msg' => 'Test message.',
44
+ 'scouts' => '2,3',
45
+ 'source' => '441234567890',
46
+ 'type' => :all,
47
+ 'scheduled' => 'now',
48
+ }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
49
+
50
+ result = Osm::Sms.send_sms(
51
+ @api,
52
+ 1, # Section
53
+ [2, 3], # Members
54
+ :all,
55
+ '441234567890', # Source address
56
+ 'Test message.' # Message text
57
+ )
58
+
59
+ result.should == {
60
+ :result => true,
61
+ :sent => 2,
62
+ :message => 'Success'
63
+ }
64
+ end
65
+
66
+ it "2 & 3" do
67
+ HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/sms.php?action=sendText&sectionid=1', {:body => {
68
+ 'apiid' => @CONFIGURATION[:api][:osm][:id],
69
+ 'token' => @CONFIGURATION[:api][:osm][:token],
70
+ 'userid' => 'user_id',
71
+ 'secret' => 'secret',
72
+ 'msg' => 'Test message.',
73
+ 'scouts' => '2,3',
74
+ 'source' => '441234567890',
75
+ 'type' => '23',
76
+ 'scheduled' => 'now',
77
+ }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
78
+
79
+ result = Osm::Sms.send_sms(
80
+ @api,
81
+ 1, # Section
82
+ [2, 3], # Members
83
+ '23',
84
+ '441234567890', # Source address
85
+ 'Test message.' # Message text
86
+ )
87
+
88
+ result.should == {
89
+ :result => true,
90
+ :sent => 2,
91
+ :message => 'Success'
92
+ }
93
+ end
94
+
95
+ it "1 & 4" do
96
+ HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/sms.php?action=sendText&sectionid=1', {:body => {
97
+ 'apiid' => @CONFIGURATION[:api][:osm][:id],
98
+ 'token' => @CONFIGURATION[:api][:osm][:token],
99
+ 'userid' => 'user_id',
100
+ 'secret' => 'secret',
101
+ 'msg' => 'Test message.',
102
+ 'scouts' => '2,3',
103
+ 'source' => '441234567890',
104
+ 'type' => '14',
105
+ 'scheduled' => 'now',
106
+ }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
107
+
108
+ result = Osm::Sms.send_sms(
109
+ @api,
110
+ 1, # Section
111
+ [2, 3], # Members
112
+ '14',
26
113
  '441234567890', # Source address
27
114
  'Test message.' # Message text
28
115
  )
@@ -191,7 +191,7 @@ describe "Term" do
191
191
  body += ']}'
192
192
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body)
193
193
 
194
- expect{ Osm::Term.get_current_term_for_section(@api, 9) }.to raise_error(Osm::Error, 'There is no current term for the section.')
194
+ expect{ Osm::Term.get_current_term_for_section(@api, 9) }.to raise_error(Osm::Error::NoCurrentTerm, 'There is no current term for the section.')
195
195
  end
196
196
  end
197
197
 
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "1.0.6"
2
+ VERSION = "1.2.0"
3
3
  end
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: 1.0.6
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -196,9 +196,12 @@ files:
196
196
  - lib/osm/api_access.rb
197
197
  - lib/osm/badge.rb
198
198
  - lib/osm/badges.rb
199
+ - lib/osm/budget.rb
199
200
  - lib/osm/event.rb
200
201
  - lib/osm/flexi_record.rb
202
+ - lib/osm/giftaid.rb
201
203
  - lib/osm/grouping.rb
204
+ - lib/osm/invoice.rb
202
205
  - lib/osm/meeting.rb
203
206
  - lib/osm/member.rb
204
207
  - lib/osm/model.rb
@@ -212,9 +215,12 @@ files:
212
215
  - spec/osm/api_spec.rb
213
216
  - spec/osm/badge_spec.rb
214
217
  - spec/osm/badges_spec.rb
218
+ - spec/osm/budget_spec.rb
215
219
  - spec/osm/event_spec.rb
216
220
  - spec/osm/flexi_record_spec.rb
221
+ - spec/osm/giftaid_spec.rb
217
222
  - spec/osm/grouping_spec.rb
223
+ - spec/osm/invoice_spec.rb
218
224
  - spec/osm/meeting_spec.rb
219
225
  - spec/osm/member_spec.rb
220
226
  - spec/osm/model_spec.rb