consul 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of consul might be problematic. Click here for more details.

data/.gitignore CHANGED
@@ -4,6 +4,3 @@ pkg
4
4
  .idea
5
5
  *.db
6
6
  app_root/log/*
7
- Gemfile.lock
8
-
9
-
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - "1.8.7"
4
4
  - "1.9.3"
5
5
  - ree
6
+ before_script: rake travis_ci:prepare
6
7
  script: rake all:bundle all:spec
7
8
  notifications:
8
9
  email:
data/README.md CHANGED
@@ -149,6 +149,28 @@ You can define multiple powers at once by giving multiple power names:
149
149
  end
150
150
 
151
151
 
152
+ Powers that require context (arguments)
153
+ ---------------------------------------
154
+
155
+ Sometimes it can be useful to define powers that require context. To do so, just take an argument in your `power` block:
156
+
157
+ class Power
158
+ ...
159
+
160
+ power :assignable_story_states do |story|
161
+ if story.finished?
162
+ %w[delivered archived]
163
+ else
164
+ %w[committed started finished]
165
+ end
166
+ end
167
+
168
+ When querying such a power, you always need to provide the context, e.g.:
169
+
170
+ story = ...
171
+ Power.current_assignable_story_state?(story, 'finished')
172
+
173
+
152
174
  Role-based permissions
153
175
  ----------------------
154
176
 
@@ -416,7 +438,7 @@ Because this pattern is so common, the `Power` class comes with a number of clas
416
438
  class UserReport
417
439
 
418
440
  def data
419
- Power.for_model(user).collect do |user|
441
+ Power.for_model(User).collect do |user|
420
442
  [user.name, user.email, user.income]
421
443
  end
422
444
  end
data/Rakefile CHANGED
@@ -4,6 +4,18 @@ require 'bundler/gem_tasks'
4
4
  desc 'Default: Run all specs.'
5
5
  task :default => 'all:spec'
6
6
 
7
+ namespace :travis_ci do
8
+
9
+ desc 'Things to do before Travis CI begins'
10
+ task :prepare => :slimgems
11
+
12
+ desc 'Install slimgems'
13
+ task :slimgems do
14
+ system('gem install slimgems')
15
+ end
16
+
17
+ end
18
+
7
19
  namespace :all do
8
20
 
9
21
  desc "Run specs on all spec apps"
data/lib/consul.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'memoizer'
2
2
  require 'edge_rider'
3
3
  require 'consul/util'
4
+ require 'consul/power/dynamic_access'
4
5
  require 'consul/power'
5
6
  require 'consul/errors'
6
7
  require 'consul/controller'
data/lib/consul/errors.rb CHANGED
@@ -5,4 +5,5 @@ module Consul
5
5
  class UnmappedAction < Error; end
6
6
  class UnreachablePower < Error; end
7
7
  class NoCollection < Error; end
8
+ class InsufficientContext < Error; end
8
9
  end
data/lib/consul/power.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Consul
2
2
  module Power
3
+ include Consul::Power::DynamicAccess::InstanceMethods
3
4
 
4
5
  def self.included(base)
5
6
  base.extend ClassMethods
@@ -8,8 +9,10 @@ module Consul
8
9
 
9
10
  def include?(name, *args)
10
11
  args = args.dup
11
- record = args.shift
12
- power_value = send(name)
12
+
13
+ context, record = context_and_record_from_args(args, name)
14
+
15
+ power_value = send(name, *context)
13
16
  if record.nil?
14
17
  !!power_value
15
18
  else
@@ -21,7 +24,7 @@ module Consul
21
24
  true
22
25
  else
23
26
  power_ids_name = self.class.power_ids_name(name)
24
- send(power_ids_name, *args).include?(record.id)
27
+ send(power_ids_name, *context).include?(record.id)
25
28
  end
26
29
  elsif Util.collection?(power_value)
27
30
  power_value.include?(record)
@@ -35,45 +38,19 @@ module Consul
35
38
  include?(*args) or raise Consul::Powerless.new("No power to #{args.inspect}")
36
39
  end
37
40
 
38
- def name_for_record(*args)
39
- adjective, record = Util.adjective_and_argument(*args)
40
- name_for_model(adjective, record.class)
41
- end
42
-
43
- def for_record(*args)
44
- send(name_for_record(*args))
45
- end
46
-
47
- def include_record?(*args)
48
- adjective, record = Util.adjective_and_argument(*args)
49
- include?(name_for_record(*args), record)
50
- end
51
-
52
- def include_record!(*args)
53
- adjective, record = Util.adjective_and_argument(*args)
54
- include!(name_for_record(*args), record)
55
- end
56
-
57
- def name_for_model(*args)
58
- adjective, model_class = Util.adjective_and_argument(*args)
59
- collection_name = model_class.name.underscore.gsub('/', '_').pluralize
60
- [adjective, collection_name].select(&:present?).join('_')
61
- end
62
-
63
- def for_model(*args)
64
- send(name_for_model(*args))
65
- end
66
-
67
- def include_model?(*args)
68
- include?(name_for_model(*args))
69
- end
41
+ private
70
42
 
71
- def include_model!(*args)
72
- include!(name_for_model(*args))
43
+ def context_and_record_from_args(args, name)
44
+ context_count = send(self.class.context_count_name(name))
45
+ context = []
46
+ context_count.times do
47
+ arg = args.shift or raise Consul::InsufficientContext, "Insufficient context for parametrized power: #{name}"
48
+ context << arg
49
+ end
50
+ record = args.shift
51
+ [context, record]
73
52
  end
74
53
 
75
- private
76
-
77
54
  def boolean_or_nil?(value)
78
55
  [TrueClass, FalseClass, NilClass].include?(value.class)
79
56
  end
@@ -83,6 +60,7 @@ module Consul
83
60
  end
84
61
 
85
62
  module ClassMethods
63
+ include Consul::Power::DynamicAccess::ClassMethods
86
64
 
87
65
  def power(*names, &block)
88
66
  names.each do |name|
@@ -90,6 +68,10 @@ module Consul
90
68
  end
91
69
  end
92
70
 
71
+ def context_count_name(name)
72
+ "#{name}_context_count"
73
+ end
74
+
93
75
  def power_ids_name(name)
94
76
  "#{name.to_s.singularize}_ids"
95
77
  end
@@ -107,56 +89,6 @@ module Consul
107
89
  self.current = old_power
108
90
  end
109
91
 
110
- def for_model(*args)
111
- if current
112
- current.for_model(*args)
113
- else
114
- adjective, model = Util.adjective_and_argument(*args)
115
- model
116
- end
117
- end
118
-
119
- def include_model?(*args)
120
- if current
121
- current.include_model?(*args)
122
- else
123
- true
124
- end
125
- end
126
-
127
- def include_model!(*args)
128
- if current
129
- current.include_model!(*args)
130
- else
131
- true
132
- end
133
- end
134
-
135
- def for_record(*args)
136
- if current
137
- current.for_record(*args)
138
- else
139
- adjective, record = Util.adjective_and_argument(*args)
140
- record.class
141
- end
142
- end
143
-
144
- def include_record?(*args)
145
- if current
146
- current.include_record?(*args)
147
- else
148
- true
149
- end
150
- end
151
-
152
- def include_record!(*args)
153
- if current
154
- current.include_record!(*args)
155
- else
156
- true
157
- end
158
- end
159
-
160
92
  private
161
93
 
162
94
  def define_power(name, &block)
@@ -165,6 +97,9 @@ module Consul
165
97
  define_method("#{name.to_s}!") { |*args| include!(name, *args) }
166
98
  define_method("#{name.to_s.singularize}?") { |*args| include?(name, *args) }
167
99
  define_method("#{name.to_s.singularize}!") { |*args| include!(name, *args) }
100
+ context_count_method = context_count_name(name)
101
+ define_method(context_count_method) { block.arity >= 0 ? block.arity : 0 }
102
+ private context_count_method
168
103
  ids_method = power_ids_name(name)
169
104
  define_method(ids_method) do |*args|
170
105
  scope = send(name, *args)
@@ -0,0 +1,102 @@
1
+ module Consul
2
+ module Power
3
+ module DynamicAccess
4
+
5
+ module InstanceMethods
6
+
7
+ def for_record(*args)
8
+ send(name_for_record(*args))
9
+ end
10
+
11
+ def include_record?(*args)
12
+ adjective, record = Util.adjective_and_argument(*args)
13
+ include?(name_for_record(*args), record)
14
+ end
15
+
16
+ def include_record!(*args)
17
+ adjective, record = Util.adjective_and_argument(*args)
18
+ include!(name_for_record(*args), record)
19
+ end
20
+
21
+ def name_for_model(*args)
22
+ adjective, model_class = Util.adjective_and_argument(*args)
23
+ collection_name = model_class.name.underscore.gsub('/', '_').pluralize
24
+ [adjective, collection_name].select(&:present?).join('_')
25
+ end
26
+
27
+ def for_model(*args)
28
+ send(name_for_model(*args))
29
+ end
30
+
31
+ def include_model?(*args)
32
+ include?(name_for_model(*args))
33
+ end
34
+
35
+ def include_model!(*args)
36
+ include!(name_for_model(*args))
37
+ end
38
+
39
+ def name_for_record(*args)
40
+ adjective, record = Util.adjective_and_argument(*args)
41
+ name_for_model(adjective, record.class)
42
+ end
43
+
44
+ end
45
+
46
+ module ClassMethods
47
+
48
+ def for_model(*args)
49
+ if current
50
+ current.for_model(*args)
51
+ else
52
+ adjective, model = Util.adjective_and_argument(*args)
53
+ model
54
+ end
55
+ end
56
+
57
+ def include_model?(*args)
58
+ if current
59
+ current.include_model?(*args)
60
+ else
61
+ true
62
+ end
63
+ end
64
+
65
+ def include_model!(*args)
66
+ if current
67
+ current.include_model!(*args)
68
+ else
69
+ true
70
+ end
71
+ end
72
+
73
+ def for_record(*args)
74
+ if current
75
+ current.for_record(*args)
76
+ else
77
+ adjective, record = Util.adjective_and_argument(*args)
78
+ record.class
79
+ end
80
+ end
81
+
82
+ def include_record?(*args)
83
+ if current
84
+ current.include_record?(*args)
85
+ else
86
+ true
87
+ end
88
+ end
89
+
90
+ def include_record!(*args)
91
+ if current
92
+ current.include_record!(*args)
93
+ else
94
+ true
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end
102
+ end
data/lib/consul/util.rb CHANGED
@@ -3,7 +3,11 @@ module Consul
3
3
  extend self
4
4
 
5
5
  def scope_selects_all_records?(scope)
6
- scope = scope.scoped({})
6
+ if Rails.version.to_i < 3
7
+ scope = scope.scoped({})
8
+ else
9
+ scope = scope.scoped
10
+ end
7
11
  scope_sql = scope.to_sql
8
12
  quoted_table_name = Regexp.quote(scope.connection.quote_table_name(scope.table_name))
9
13
  all_sql_pattern = /\ASELECT (#{quoted_table_name}\.)?\* FROM #{quoted_table_name}\z/
@@ -1,3 +1,3 @@
1
1
  module Consul
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -4,10 +4,11 @@ gem 'assignable_values'
4
4
  gem 'rails', '~>2.3'
5
5
  gem 'rspec', '~>1.3'
6
6
  gem 'rspec-rails', '~>1.3'
7
- gem 'shoulda-matchers'
7
+ gem 'shoulda-matchers', '<2'
8
8
  gem 'sqlite3'
9
9
  gem 'rspec_candy'
10
10
  gem 'ruby-debug', :platforms => :mri_18
11
11
  gem 'test-unit', '~>1.2', :platforms => :ruby_19
12
+ gem 'hoe', '=2.8.0', :platforms => :ruby_19
12
13
 
13
14
  gem 'consul', :path => '../..'
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ consul (0.7.0)
5
+ edge_rider
6
+ memoizer
7
+ rails
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (2.3.18)
13
+ actionpack (= 2.3.18)
14
+ actionpack (2.3.18)
15
+ activesupport (= 2.3.18)
16
+ rack (~> 1.1.0)
17
+ activerecord (2.3.18)
18
+ activesupport (= 2.3.18)
19
+ activeresource (2.3.18)
20
+ activesupport (= 2.3.18)
21
+ activesupport (2.3.18)
22
+ assignable_values (0.7.1)
23
+ activerecord
24
+ columnize (0.3.6)
25
+ edge_rider (0.2.1)
26
+ rails
27
+ hoe (2.8.0)
28
+ rake (>= 0.8.7)
29
+ linecache (0.46)
30
+ rbx-require-relative (> 0.0.4)
31
+ memoizer (1.0.1)
32
+ rack (1.1.6)
33
+ rails (2.3.18)
34
+ actionmailer (= 2.3.18)
35
+ actionpack (= 2.3.18)
36
+ activerecord (= 2.3.18)
37
+ activeresource (= 2.3.18)
38
+ activesupport (= 2.3.18)
39
+ rake (>= 0.8.3)
40
+ rake (10.0.4)
41
+ rbx-require-relative (0.0.9)
42
+ rspec (1.3.2)
43
+ rspec-rails (1.3.4)
44
+ rack (>= 1.0.0)
45
+ rspec (~> 1.3.1)
46
+ rspec_candy (0.2.9)
47
+ rspec
48
+ sneaky-save
49
+ ruby-debug (0.10.4)
50
+ columnize (>= 0.1)
51
+ ruby-debug-base (~> 0.10.4.0)
52
+ ruby-debug-base (0.10.4)
53
+ linecache (>= 0.3)
54
+ shoulda-matchers (1.0.0)
55
+ sneaky-save (0.0.2)
56
+ activerecord (>= 2.3.2)
57
+ sqlite3 (1.3.7)
58
+ test-unit (1.2.3)
59
+ hoe (>= 1.5.1)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ assignable_values
66
+ consul!
67
+ hoe (= 2.8.0)
68
+ rails (~> 2.3)
69
+ rspec (~> 1.3)
70
+ rspec-rails (~> 1.3)
71
+ rspec_candy
72
+ ruby-debug
73
+ shoulda-matchers (< 2)
74
+ sqlite3
75
+ test-unit (~> 1.2)
@@ -4,7 +4,7 @@ gem 'assignable_values'
4
4
  gem 'rails', '~>3.0.17'
5
5
  gem 'rspec'
6
6
  gem 'rspec-rails'
7
- gem 'shoulda-matchers'
7
+ gem 'shoulda-matchers', '<2'
8
8
  gem 'sqlite3'
9
9
  gem 'rspec_candy'
10
10
  gem 'ruby-debug', :platforms => :mri_18
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ consul (0.7.0)
5
+ edge_rider
6
+ memoizer
7
+ rails
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ abstract (1.0.0)
13
+ actionmailer (3.0.20)
14
+ actionpack (= 3.0.20)
15
+ mail (~> 2.2.19)
16
+ actionpack (3.0.20)
17
+ activemodel (= 3.0.20)
18
+ activesupport (= 3.0.20)
19
+ builder (~> 2.1.2)
20
+ erubis (~> 2.6.6)
21
+ i18n (~> 0.5.0)
22
+ rack (~> 1.2.5)
23
+ rack-mount (~> 0.6.14)
24
+ rack-test (~> 0.5.7)
25
+ tzinfo (~> 0.3.23)
26
+ activemodel (3.0.20)
27
+ activesupport (= 3.0.20)
28
+ builder (~> 2.1.2)
29
+ i18n (~> 0.5.0)
30
+ activerecord (3.0.20)
31
+ activemodel (= 3.0.20)
32
+ activesupport (= 3.0.20)
33
+ arel (~> 2.0.10)
34
+ tzinfo (~> 0.3.23)
35
+ activeresource (3.0.20)
36
+ activemodel (= 3.0.20)
37
+ activesupport (= 3.0.20)
38
+ activesupport (3.0.20)
39
+ arel (2.0.10)
40
+ assignable_values (0.7.1)
41
+ activerecord
42
+ bourne (1.4.0)
43
+ mocha (~> 0.13.2)
44
+ builder (2.1.2)
45
+ columnize (0.3.6)
46
+ diff-lcs (1.2.4)
47
+ edge_rider (0.2.1)
48
+ rails
49
+ erubis (2.6.6)
50
+ abstract (>= 1.0.0)
51
+ i18n (0.5.0)
52
+ json (1.8.0)
53
+ linecache (0.46)
54
+ rbx-require-relative (> 0.0.4)
55
+ mail (2.2.20)
56
+ activesupport (>= 2.3.6)
57
+ i18n (>= 0.4.0)
58
+ mime-types (~> 1.16)
59
+ treetop (~> 1.4.8)
60
+ memoizer (1.0.1)
61
+ metaclass (0.0.1)
62
+ mime-types (1.23)
63
+ mocha (0.13.3)
64
+ metaclass (~> 0.0.1)
65
+ polyglot (0.3.3)
66
+ rack (1.2.8)
67
+ rack-mount (0.6.14)
68
+ rack (>= 1.0.0)
69
+ rack-test (0.5.7)
70
+ rack (>= 1.0)
71
+ rails (3.0.20)
72
+ actionmailer (= 3.0.20)
73
+ actionpack (= 3.0.20)
74
+ activerecord (= 3.0.20)
75
+ activeresource (= 3.0.20)
76
+ activesupport (= 3.0.20)
77
+ bundler (~> 1.0)
78
+ railties (= 3.0.20)
79
+ railties (3.0.20)
80
+ actionpack (= 3.0.20)
81
+ activesupport (= 3.0.20)
82
+ rake (>= 0.8.7)
83
+ rdoc (~> 3.4)
84
+ thor (~> 0.14.4)
85
+ rake (10.0.4)
86
+ rbx-require-relative (0.0.9)
87
+ rdoc (3.12.2)
88
+ json (~> 1.4)
89
+ rspec (2.13.0)
90
+ rspec-core (~> 2.13.0)
91
+ rspec-expectations (~> 2.13.0)
92
+ rspec-mocks (~> 2.13.0)
93
+ rspec-core (2.13.1)
94
+ rspec-expectations (2.13.0)
95
+ diff-lcs (>= 1.1.3, < 2.0)
96
+ rspec-mocks (2.13.1)
97
+ rspec-rails (2.13.1)
98
+ actionpack (>= 3.0)
99
+ activesupport (>= 3.0)
100
+ railties (>= 3.0)
101
+ rspec-core (~> 2.13.0)
102
+ rspec-expectations (~> 2.13.0)
103
+ rspec-mocks (~> 2.13.0)
104
+ rspec_candy (0.2.9)
105
+ rspec
106
+ sneaky-save
107
+ ruby-debug (0.10.4)
108
+ columnize (>= 0.1)
109
+ ruby-debug-base (~> 0.10.4.0)
110
+ ruby-debug-base (0.10.4)
111
+ linecache (>= 0.3)
112
+ shoulda-matchers (1.5.6)
113
+ activesupport (>= 3.0.0)
114
+ bourne (~> 1.3)
115
+ sneaky-save (0.0.2)
116
+ activerecord (>= 2.3.2)
117
+ sqlite3 (1.3.7)
118
+ thor (0.14.6)
119
+ treetop (1.4.12)
120
+ polyglot
121
+ polyglot (>= 0.3.1)
122
+ tzinfo (0.3.37)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ assignable_values
129
+ consul!
130
+ rails (~> 3.0.17)
131
+ rspec
132
+ rspec-rails
133
+ rspec_candy
134
+ ruby-debug
135
+ shoulda-matchers (< 2)
136
+ sqlite3
@@ -4,7 +4,7 @@ gem 'assignable_values'
4
4
  gem 'rails', '~>3.2.0'
5
5
  gem 'rspec'
6
6
  gem 'rspec-rails'
7
- gem 'shoulda-matchers'
7
+ gem 'shoulda-matchers', '<2'
8
8
  gem 'sqlite3'
9
9
  gem 'rspec_candy'
10
10
  gem 'ruby-debug', :platforms => :mri_18
@@ -0,0 +1,145 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ consul (0.7.0)
5
+ edge_rider
6
+ memoizer
7
+ rails
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ actionmailer (3.2.13)
13
+ actionpack (= 3.2.13)
14
+ mail (~> 2.5.3)
15
+ actionpack (3.2.13)
16
+ activemodel (= 3.2.13)
17
+ activesupport (= 3.2.13)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.4)
21
+ rack (~> 1.4.5)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.2.1)
25
+ activemodel (3.2.13)
26
+ activesupport (= 3.2.13)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.13)
29
+ activemodel (= 3.2.13)
30
+ activesupport (= 3.2.13)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.13)
34
+ activemodel (= 3.2.13)
35
+ activesupport (= 3.2.13)
36
+ activesupport (3.2.13)
37
+ i18n (= 0.6.1)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ assignable_values (0.7.1)
41
+ activerecord
42
+ bourne (1.4.0)
43
+ mocha (~> 0.13.2)
44
+ builder (3.0.4)
45
+ columnize (0.3.6)
46
+ diff-lcs (1.2.4)
47
+ edge_rider (0.2.1)
48
+ rails
49
+ erubis (2.7.0)
50
+ hike (1.2.2)
51
+ i18n (0.6.1)
52
+ journey (1.0.4)
53
+ json (1.8.0)
54
+ linecache (0.46)
55
+ rbx-require-relative (> 0.0.4)
56
+ mail (2.5.4)
57
+ mime-types (~> 1.16)
58
+ treetop (~> 1.4.8)
59
+ memoizer (1.0.1)
60
+ metaclass (0.0.1)
61
+ mime-types (1.23)
62
+ mocha (0.13.3)
63
+ metaclass (~> 0.0.1)
64
+ multi_json (1.7.3)
65
+ polyglot (0.3.3)
66
+ rack (1.4.5)
67
+ rack-cache (1.2)
68
+ rack (>= 0.4)
69
+ rack-ssl (1.3.3)
70
+ rack
71
+ rack-test (0.6.2)
72
+ rack (>= 1.0)
73
+ rails (3.2.13)
74
+ actionmailer (= 3.2.13)
75
+ actionpack (= 3.2.13)
76
+ activerecord (= 3.2.13)
77
+ activeresource (= 3.2.13)
78
+ activesupport (= 3.2.13)
79
+ bundler (~> 1.0)
80
+ railties (= 3.2.13)
81
+ railties (3.2.13)
82
+ actionpack (= 3.2.13)
83
+ activesupport (= 3.2.13)
84
+ rack-ssl (~> 1.3.2)
85
+ rake (>= 0.8.7)
86
+ rdoc (~> 3.4)
87
+ thor (>= 0.14.6, < 2.0)
88
+ rake (10.0.4)
89
+ rbx-require-relative (0.0.9)
90
+ rdoc (3.12.2)
91
+ json (~> 1.4)
92
+ rspec (2.13.0)
93
+ rspec-core (~> 2.13.0)
94
+ rspec-expectations (~> 2.13.0)
95
+ rspec-mocks (~> 2.13.0)
96
+ rspec-core (2.13.1)
97
+ rspec-expectations (2.13.0)
98
+ diff-lcs (>= 1.1.3, < 2.0)
99
+ rspec-mocks (2.13.1)
100
+ rspec-rails (2.13.1)
101
+ actionpack (>= 3.0)
102
+ activesupport (>= 3.0)
103
+ railties (>= 3.0)
104
+ rspec-core (~> 2.13.0)
105
+ rspec-expectations (~> 2.13.0)
106
+ rspec-mocks (~> 2.13.0)
107
+ rspec_candy (0.2.9)
108
+ rspec
109
+ sneaky-save
110
+ ruby-debug (0.10.4)
111
+ columnize (>= 0.1)
112
+ ruby-debug-base (~> 0.10.4.0)
113
+ ruby-debug-base (0.10.4)
114
+ linecache (>= 0.3)
115
+ shoulda-matchers (1.5.6)
116
+ activesupport (>= 3.0.0)
117
+ bourne (~> 1.3)
118
+ sneaky-save (0.0.4)
119
+ activerecord (>= 3.2.0)
120
+ sprockets (2.2.2)
121
+ hike (~> 1.2)
122
+ multi_json (~> 1.0)
123
+ rack (~> 1.0)
124
+ tilt (~> 1.1, != 1.3.0)
125
+ sqlite3 (1.3.7)
126
+ thor (0.18.1)
127
+ tilt (1.4.1)
128
+ treetop (1.4.12)
129
+ polyglot
130
+ polyglot (>= 0.3.1)
131
+ tzinfo (0.3.37)
132
+
133
+ PLATFORMS
134
+ ruby
135
+
136
+ DEPENDENCIES
137
+ assignable_values
138
+ consul!
139
+ rails (~> 3.2.0)
140
+ rspec
141
+ rspec-rails
142
+ rspec_candy
143
+ ruby-debug
144
+ shoulda-matchers (< 2)
145
+ sqlite3
@@ -132,6 +132,19 @@ describe Consul::Power do
132
132
  @user.power.recent_song?(Song.new)
133
133
  end
134
134
 
135
+ it 'should work with powers that have arguments' do
136
+ @user.power.client_note?(@client1, @client1_note1).should be_true
137
+ @user.power.client_note?(@client1, @client2_note1).should be_false
138
+ end
139
+
140
+ end
141
+
142
+ context 'when a power with arguments is given insufficient context' do
143
+
144
+ it 'should raise an error' do
145
+ expect { @user.power.client_notes? }.to raise_error(Consul::InsufficientContext)
146
+ end
147
+
135
148
  end
136
149
 
137
150
  end
@@ -156,6 +169,11 @@ describe Consul::Power do
156
169
  expect { @user.power.client!(@client1) }.to_not raise_error
157
170
  end
158
171
 
172
+ it 'should work with scopes that have arguments' do
173
+ expect { @user.power.client_note!(@client1, @client1_note1) }.to_not raise_error
174
+ expect { @user.power.client_note!(@client1, @client2_note1) }.to raise_error(Consul::Powerless)
175
+ end
176
+
159
177
  end
160
178
 
161
179
  end
@@ -175,6 +193,10 @@ describe Consul::Power do
175
193
  expect { @user.power.note_ids }.to_not raise_error
176
194
  end
177
195
 
196
+ it 'should work with scopes that have arguments' do
197
+ @user.power.client_note_ids(@client1).should =~ [@client1_note1.id, @client1_note2.id]
198
+ end
199
+
178
200
  end
179
201
 
180
202
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-02-11 00:00:00 +01:00
18
+ date: 2013-05-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -79,10 +79,12 @@ files:
79
79
  - lib/consul/controller.rb
80
80
  - lib/consul/errors.rb
81
81
  - lib/consul/power.rb
82
+ - lib/consul/power/dynamic_access.rb
82
83
  - lib/consul/spec/matchers.rb
83
84
  - lib/consul/util.rb
84
85
  - lib/consul/version.rb
85
86
  - spec/rails-2.3/Gemfile
87
+ - spec/rails-2.3/Gemfile.lock
86
88
  - spec/rails-2.3/Rakefile
87
89
  - spec/rails-2.3/app_root/config/boot.rb
88
90
  - spec/rails-2.3/app_root/config/database.yml
@@ -101,6 +103,7 @@ files:
101
103
  - spec/rails-2.3/spec/spec_helper.rb
102
104
  - spec/rails-3.0/.rspec
103
105
  - spec/rails-3.0/Gemfile
106
+ - spec/rails-3.0/Gemfile.lock
104
107
  - spec/rails-3.0/Rakefile
105
108
  - spec/rails-3.0/app_root/.gitignore
106
109
  - spec/rails-3.0/app_root/config/application.rb
@@ -121,6 +124,7 @@ files:
121
124
  - spec/rails-3.0/spec/spec_helper.rb
122
125
  - spec/rails-3.2/.rspec
123
126
  - spec/rails-3.2/Gemfile
127
+ - spec/rails-3.2/Gemfile.lock
124
128
  - spec/rails-3.2/Rakefile
125
129
  - spec/rails-3.2/app_root/.gitignore
126
130
  - spec/rails-3.2/app_root/config/application.rb