osm 1.0.4.dev → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  ## Version 1.0.4
2
2
 
3
- *
3
+ * Add notice board option to getting My.SCOUT link for a member (pass :notice as the parameter)
4
+ * Model.require\_ability\_to now only checks subscription level for youth sections
4
5
 
5
6
  ## Version 1.0.3
6
7
 
@@ -369,7 +369,7 @@ module Osm
369
369
 
370
370
  # Get the My.SCOUT link for this member
371
371
  # @param [Osm::Api] api The api to use to make the request
372
- # @param [Symbol] link_to The page in My.SCOUT to link to (:payments, :events, :programme or :badges)
372
+ # @param [Symbol] link_to The page in My.SCOUT to link to (:payments, :events, :programme, :badges or :notice)
373
373
  # @return [String] the link for this member's My.SCOUT
374
374
  # @raise [Osm::ObjectIsInvalid] If the Member is invalid
375
375
  # @raise [Osm::ArgumentIsInvalid] If link_to is not an allowed Symbol
@@ -378,7 +378,7 @@ module Osm
378
378
  raise Osm::ObjectIsInvalid, 'member is invalid' unless valid?
379
379
  require_ability_to(api, :read, :member, section_id)
380
380
  raise Osm::Error, 'the member does not already exist in OSM' if id.nil?
381
- raise Osm::ArgumentIsInvalid, 'link_to is invalid' unless [:payments, :events, :programme, :badges].include?(link_to)
381
+ raise Osm::ArgumentIsInvalid, 'link_to is invalid' unless [:payments, :events, :programme, :badges, :notice].include?(link_to)
382
382
 
383
383
  if @myscout_link_key.nil?
384
384
  data = api.perform_query("api.php?action=getMyScoutKey&sectionid=#{section_id}&scoutid=#{self.id}")
@@ -178,6 +178,7 @@ module Osm
178
178
  end
179
179
  end
180
180
  if section.nil? || section.subscription_level < level
181
+ level_name = ['Unknown', 'Bronze', 'Silver', 'Gold'][level]
181
182
  raise Osm::Forbidden, "Insufficent OSM subscription level (#{level} required for #{section.name})"
182
183
  end
183
184
  end
@@ -190,8 +191,12 @@ module Osm
190
191
  # @!macro options_get
191
192
  def self.require_ability_to(api, to, on, section, options={})
192
193
  require_permission(api, to, on, section, options)
193
- require_subscription(api, :silver, section, options) if [:register, :contact, :events, :flexi].include?(on)
194
- require_subscription(api, :gold, section, options) if [:finance].include?(on)
194
+ if section.youth_section? && [:register, :contact, :events, :flexi].include?(on)
195
+ require_subscription(api, :silver, section, options)
196
+ end
197
+ if section.youth_section? && [:finance].include?(on)
198
+ require_subscription(api, :gold, section, options)
199
+ end
195
200
  end
196
201
 
197
202
 
@@ -495,9 +495,7 @@ describe "Member" do
495
495
  :grouping_id => '3',
496
496
  :grouping_leader => 0,
497
497
  )
498
- end
499
498
 
500
- it "Default" do
501
499
  url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
502
500
  HTTParty.should_receive(:post).with(url, {:body => {
503
501
  'apiid' => @CONFIGURATION[:api][:osm][:id],
@@ -505,39 +503,34 @@ describe "Member" do
505
503
  'userid' => 'user_id',
506
504
  'secret' => 'secret',
507
505
  }}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true,"key":"KEY-HERE"}'}) }
506
+ end
507
+
508
+ it "Default" do
508
509
  @member.myscout_link(@api).should == 'https://www.onlinescoutmanager.co.uk/parents/badges.php?sc=1&se=2&c=KEY-HERE'
509
510
  end
510
511
 
511
512
  it "Payments" do
512
- url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
513
- FakeWeb.register_uri(:post, url, :body => '{"ok":true,"key":"KEY-HERE"}')
514
513
  @member.myscout_link(@api, :payments).should == 'https://www.onlinescoutmanager.co.uk/parents/payments.php?sc=1&se=2&c=KEY-HERE'
515
514
  end
516
515
 
517
516
  it "Events" do
518
- url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
519
- FakeWeb.register_uri(:post, url, :body => '{"ok":true,"key":"KEY-HERE"}')
520
517
  @member.myscout_link(@api, :events).should == 'https://www.onlinescoutmanager.co.uk/parents/events.php?sc=1&se=2&c=KEY-HERE'
521
518
  end
522
519
 
523
520
  it "Programme" do
524
- url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
525
- FakeWeb.register_uri(:post, url, :body => '{"ok":true,"key":"KEY-HERE"}')
526
521
  @member.myscout_link(@api, :programme).should == 'https://www.onlinescoutmanager.co.uk/parents/programme.php?sc=1&se=2&c=KEY-HERE'
527
522
  end
528
523
 
529
524
  it "Badges" do
530
- url = 'https://www.onlinescoutmanager.co.uk/api.php?action=getMyScoutKey&sectionid=2&scoutid=1'
531
- FakeWeb.register_uri(:post, url, :body => '{"ok":true,"key":"KEY-HERE"}')
532
525
  @member.myscout_link(@api, :badges).should == 'https://www.onlinescoutmanager.co.uk/parents/badges.php?sc=1&se=2&c=KEY-HERE'
533
526
  end
534
527
 
535
- it "Invalid" do
536
- expect{ @member.myscout_link(@api, :invalid) }.to raise_error(Osm::ArgumentIsInvalid)
528
+ it "Notice board" do
529
+ @member.myscout_link(@api, :notice).should == 'https://www.onlinescoutmanager.co.uk/parents/notice.php?sc=1&se=2&c=KEY-HERE'
537
530
  end
538
531
 
539
532
  end
540
533
 
541
534
  end
542
535
 
543
- end
536
+ end
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "1.0.4.dev"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4.dev
5
- prerelease: 6
4
+ version: 1.0.4
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert Gauld
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -240,9 +240,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  none: false
242
242
  requirements:
243
- - - ! '>'
243
+ - - ! '>='
244
244
  - !ruby/object:Gem::Version
245
- version: 1.3.1
245
+ version: '0'
246
246
  requirements: []
247
247
  rubyforge_project: osm
248
248
  rubygems_version: 1.8.25