osm 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## Version 0.6.2
2
+
3
+ * Fix items not relevant to API appearing in permissions for a Section
4
+ * Fix started and started? methods for staged badges which have been completly done
5
+
1
6
  ## Version 0.6.1
2
7
 
3
8
  * Fixes to adventure badges
data/lib/osm.rb CHANGED
@@ -139,7 +139,10 @@ module Osm
139
139
  }
140
140
 
141
141
  return permissions.inject({}) do |new_hash, (key, value)|
142
- new_hash[key.to_sym] = (permissions_map[value.to_i] || [])
142
+ if ["badge", "member", "user", "register", "contact", "programme","events", "flexi", "finance"].include?(key)
143
+ # This is a permission we care about
144
+ new_hash[key.to_sym] = permissions_map[value.to_i]
145
+ end
143
146
  new_hash
144
147
  end
145
148
  end
@@ -385,6 +385,7 @@ module Osm
385
385
  end
386
386
  else
387
387
  # 'Normal' staged badge
388
+ return 0 if completed == 5 || awarded == 5 # No more stages can be started
388
389
  start_group = 'abcde'[completed] # Requirements use the group letter to denote stage
389
390
  started = 'z'
390
391
  requirements.each do |key, value|
@@ -68,12 +68,12 @@ describe "API" do
68
68
 
69
69
  it "Get from API" do
70
70
  body = [
71
- {"sectionid"=>"1", "permissions"=>{"a"=>20}},
72
- {"sectionid"=>"2", "permissions"=>{"a"=>10}}
71
+ {"sectionid"=>"1", "permissions"=>{"badge"=>20}},
72
+ {"sectionid"=>"2", "permissions"=>{"badge"=>10}}
73
73
  ]
74
74
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
75
75
 
76
- permissions = {1 => {:a => [:read, :write]}, 2 => {:a => [:read]}}
76
+ permissions = {1 => {:badge => [:read, :write]}, 2 => {:badge => [:read]}}
77
77
  OsmTest::Cache.should_not_receive('read')
78
78
  @api.get_user_permissions.should == permissions
79
79
  end
@@ -87,7 +87,7 @@ describe "API" do
87
87
 
88
88
  it "Get ignoring cache" do
89
89
  data = [
90
- {"sectionid"=>"1", "permissions"=>{"a"=>10}},
90
+ {"sectionid"=>"1", "permissions"=>{"badge"=>10}},
91
91
  ]
92
92
  body = {
93
93
  'apiid' => @CONFIGURATION[:api][:osm][:id],
@@ -100,7 +100,7 @@ describe "API" do
100
100
  OsmTest::Cache.should_not_receive('exist?').with('OSMAPI-osm-permissions-user_id')
101
101
  OsmTest::Cache.should_not_receive('read').with('OSMAPI-osm-permissions-user_id')
102
102
  HTTParty.should_receive(:post).with(url, {:body=>body}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>data.to_json}) }
103
- @api.get_user_permissions(:no_cache => true).should == {1 => {:a => [:read]}}
103
+ @api.get_user_permissions(:no_cache => true).should == {1 => {:badge => [:read]}}
104
104
  end
105
105
 
106
106
  it "Set" do
@@ -206,6 +206,11 @@ describe "Badge" do
206
206
  :requirements => {'a_01' => 'Yes', 'b_01' => 'Yes', 'b_02' => '', 'c_01' => 'Yes', 'c_02' => ''},
207
207
  :completed => 1,
208
208
  ).started.should == 2
209
+ Osm::Badge::Data.new(
210
+ :badge => Osm::StagedBadge.new(:osm_key => 'test'),
211
+ :requirements => {'a_01' => '', 'b_01' => '', 'c_01' => '', 'd_01' => '', 'e_01' => ''},
212
+ :completed => 5,
213
+ ).started.should == 0 # No more stages to do
209
214
  Osm::Badge::Data.new(
210
215
  :badge => Osm::StagedBadge.new(:osm_key => 'nightsaway'),
211
216
  :requirements => {'a_01' => 7, 'y_01' => '7', 'custom_26695' => ''},
@@ -83,4 +83,31 @@ describe "Online Scout Manager" do
83
83
 
84
84
  end
85
85
 
86
+
87
+ describe "Make permissions Hash" do
88
+
89
+ it "Make the hash" do
90
+ from_osm = {
91
+ 'badge' => 100,
92
+ 'programme' => 20,
93
+ 'events' => 10,
94
+ }
95
+ Osm.make_permissions_hash(from_osm).should == {
96
+ :badge => [:read, :write, :administer],
97
+ :programme => [:read, :write],
98
+ :events => [:read],
99
+ }
100
+ end
101
+
102
+ it "Includes only relevant permissions" do
103
+ from_osm = {
104
+ 't' => true,
105
+ 'f' => false,
106
+ 'badge' => 100,
107
+ }
108
+ Osm.make_permissions_hash(from_osm).keys.should == [:badge]
109
+ end
110
+
111
+ end
112
+
86
113
  end
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
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: 0.6.1
4
+ version: 0.6.2
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-04-06 00:00:00.000000000 Z
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport