strong_actions 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f33bd237fe0db5884816fedd3d3d8be5c61bc65
4
- data.tar.gz: d61a5a34fde02ded12c2943e5d22ed0c7382b4f8
3
+ metadata.gz: 31fc4f5e9191a56ec48d3f35fdb424deaa0371ae
4
+ data.tar.gz: 8a4e24d7bb75c0930820a4856b87bfc1f56a6fc2
5
5
  SHA512:
6
- metadata.gz: ea2429d1c839a9b318f7bca17dea13be8cc60448856165c2d996e3baf2913e31aa17d5f4608e0f724bb3b43ecad811d33f3d2ae8f230da2a700ac324190eab2c
7
- data.tar.gz: 7cf82ccdebb20b21bb570372144f46edd20aa30c71c828f8396ab7c205e7aec92089c56c67ebf576cb20bab605d9d5059834c2df361d8bc72258220fa6a3d431
6
+ metadata.gz: d71a0a3d851fdd2b8e7b95706e4a4040849cf4fca180f1fb11d673bcee0f7c04f88a1072a1391b0a2d77ddf39c7a1003107e5cd87fcb5cce7f88ae7bf1d84615
7
+ data.tar.gz: de3ee53a2db2ee226297b46a1e7dc1b9f54c6117e6992fb69a0d5266d1b13f8d52b3ba8935b657a69e61077cba2d73db55fdc6f38f5993b3800798f305bef44f
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in strong_actions.gemspec
4
4
  gemspec
5
-
6
- gem "actionpack", "~> 3.2.0"
7
- gem "railties", "~> 3.2.0"
data/Gemfile.lock CHANGED
@@ -9,62 +9,45 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (3.2.19)
13
- activemodel (= 3.2.19)
14
- activesupport (= 3.2.19)
15
- builder (~> 3.0.0)
12
+ actionpack (4.1.6)
13
+ actionview (= 4.1.6)
14
+ activesupport (= 4.1.6)
15
+ rack (~> 1.5.2)
16
+ rack-test (~> 0.6.2)
17
+ actionview (4.1.6)
18
+ activesupport (= 4.1.6)
19
+ builder (~> 3.1)
16
20
  erubis (~> 2.7.0)
17
- journey (~> 1.0.4)
18
- rack (~> 1.4.5)
19
- rack-cache (~> 1.2)
20
- rack-test (~> 0.6.1)
21
- sprockets (~> 2.2.1)
22
- activemodel (3.2.19)
23
- activesupport (= 3.2.19)
24
- builder (~> 3.0.0)
25
- activesupport (3.2.19)
26
- i18n (~> 0.6, >= 0.6.4)
27
- multi_json (~> 1.0)
28
- builder (3.0.4)
21
+ activesupport (4.1.6)
22
+ i18n (~> 0.6, >= 0.6.9)
23
+ json (~> 1.7, >= 1.7.7)
24
+ minitest (~> 5.1)
25
+ thread_safe (~> 0.1)
26
+ tzinfo (~> 1.1)
27
+ builder (3.2.2)
29
28
  erubis (2.7.0)
30
- hike (1.2.3)
31
29
  i18n (0.6.11)
32
- journey (1.0.4)
33
30
  json (1.8.1)
34
- minitest (5.4.1)
35
- multi_json (1.10.1)
36
- rack (1.4.5)
37
- rack-cache (1.2)
38
- rack (>= 0.4)
39
- rack-ssl (1.3.4)
40
- rack
31
+ minitest (5.4.2)
32
+ rack (1.5.2)
41
33
  rack-test (0.6.2)
42
34
  rack (>= 1.0)
43
- railties (3.2.19)
44
- actionpack (= 3.2.19)
45
- activesupport (= 3.2.19)
46
- rack-ssl (~> 1.3.2)
35
+ railties (4.1.6)
36
+ actionpack (= 4.1.6)
37
+ activesupport (= 4.1.6)
47
38
  rake (>= 0.8.7)
48
- rdoc (~> 3.4)
49
- thor (>= 0.14.6, < 2.0)
39
+ thor (>= 0.18.1, < 2.0)
50
40
  rake (10.3.2)
51
- rdoc (3.12.2)
52
- json (~> 1.4)
53
- sprockets (2.2.2)
54
- hike (~> 1.2)
55
- multi_json (~> 1.0)
56
- rack (~> 1.0)
57
- tilt (~> 1.1, != 1.3.0)
58
41
  thor (0.19.1)
59
- tilt (1.4.1)
42
+ thread_safe (0.3.4)
43
+ tzinfo (1.2.2)
44
+ thread_safe (~> 0.1)
60
45
 
61
46
  PLATFORMS
62
47
  ruby
63
48
 
64
49
  DEPENDENCIES
65
- actionpack (~> 3.2.0)
66
50
  bundler (~> 1.6)
67
51
  minitest
68
- railties (~> 3.2.0)
69
52
  rake
70
53
  strong_actions!
data/HISTORY.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # History
2
2
 
3
+ ## 0.0.5
4
+ * do not raise error when role is undefined but not needed.
5
+
3
6
  ## 0.0.4
4
7
  * test
5
8
 
@@ -1,4 +1,5 @@
1
1
  require 'singleton'
2
+ require 'yaml'
2
3
 
3
4
  module StrongActions
4
5
  class Config
@@ -9,12 +9,6 @@ module StrongActions
9
9
  role_definition = StrongActions.config.role_definition(role)
10
10
  return true unless role_definition
11
11
 
12
- begin
13
- role_object = @target.instance_eval(role)
14
- rescue NameError
15
- raise "role #{role} is not defined in controller"
16
- end
17
-
18
12
  controller_value = role_definition[controller_name]
19
13
  return true if controller_value.nil?
20
14
 
@@ -30,11 +24,21 @@ module StrongActions
30
24
  action_value.each do |definition|
31
25
  next if definition === true
32
26
  return false unless definition
27
+
28
+ role_object = role_object_for(role)
33
29
  return false unless role_object.instance_eval(definition)
34
30
  end
35
31
 
36
32
  true
37
33
  end
38
-
34
+
35
+ def role_object_for(role)
36
+ begin
37
+ return @target.instance_eval(role)
38
+ rescue NameError
39
+ raise "role #{role} is not defined in controller"
40
+ end
41
+ end
42
+
39
43
  end
40
44
  end
@@ -1,3 +1,3 @@
1
1
  module StrongActions
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -45,6 +45,11 @@ class DecisionTest < Minitest::Test
45
45
  assert decision.call('current_user', 'stores', 'new')
46
46
  end
47
47
 
48
+ def test_role_undefined_and_not_needed
49
+ assert decision.call('current_user', 'some_actions')
50
+ assert decision.call('undefined', 'some_actions')
51
+ end
52
+
48
53
  end
49
54
 
50
55
  class User
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-28 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.2.2
160
+ rubygems_version: 2.4.1
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: access control for rails controller/action
@@ -165,3 +165,4 @@ test_files:
165
165
  - test/config/acl.yml
166
166
  - test/decision_test.rb
167
167
  - test/test_helper.rb
168
+ has_rdoc: