cream 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/cream.gemspec +13 -13
- data/lib/cream/configure/after_init/role_config.rb +1 -1
- data/lib/cream/configure/rails.rb +1 -1
- data/lib/cream/role.rb +1 -1
- data/lib/cream/view/role_area.rb +1 -1
- data/spec/configure_helper.rb +17 -0
- data/spec/cream/configure/rails_spec.rb +12 -29
- data/spec/cream/helper/role_spec.rb +21 -21
- data/spec/cream/view/role_area_spec.rb +37 -29
- metadata +10 -10
- data/spec/cream/view/role_ext_spec.rb +0 -36
data/Rakefile
CHANGED
@@ -15,9 +15,9 @@ begin
|
|
15
15
|
|
16
16
|
gem.add_dependency "require_all", "~> 1.2.0"
|
17
17
|
|
18
|
-
gem.add_dependency "devise-links", "~> 0.1.
|
19
|
-
gem.add_dependency "cancan-rest-links", "~> 0.1.
|
20
|
-
gem.add_dependency "cancan-permits", "~> 0.1.
|
18
|
+
gem.add_dependency "devise-links", "~> 0.1.2"
|
19
|
+
gem.add_dependency "cancan-rest-links", "~> 0.1.2"
|
20
|
+
gem.add_dependency "cancan-permits", "~> 0.1.3"
|
21
21
|
|
22
22
|
gem.add_dependency "devise", ">= 1.1.2"
|
23
23
|
gem.add_dependency "cancan", "~> 1.3.4"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.8
|
data/cream.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cream}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
@@ -62,12 +62,12 @@ Gem::Specification.new do |s|
|
|
62
62
|
"lib/generators/cream_refactor.rb",
|
63
63
|
"log/development.log",
|
64
64
|
"sandbox/test.rb",
|
65
|
+
"spec/configure_helper.rb",
|
65
66
|
"spec/cream/configure/rails_spec.rb",
|
66
67
|
"spec/cream/helper/host_spec.rb",
|
67
68
|
"spec/cream/helper/role_spec.rb",
|
68
69
|
"spec/cream/view/host_area_spec.rb",
|
69
70
|
"spec/cream/view/role_area_spec.rb",
|
70
|
-
"spec/cream/view/role_ext_spec.rb",
|
71
71
|
"spec/generator_spec_helper.rb",
|
72
72
|
"spec/generators/cream/config/devise/existing_devise_users.rb",
|
73
73
|
"spec/generators/cream/config/empty_app/default_args_spec.rb",
|
@@ -93,12 +93,12 @@ Gem::Specification.new do |s|
|
|
93
93
|
s.rubygems_version = %q{1.3.7}
|
94
94
|
s.summary = %q{Integrates Devise, Roles and CanCan with Permits for a Rails 3 app}
|
95
95
|
s.test_files = [
|
96
|
-
"spec/
|
96
|
+
"spec/configure_helper.rb",
|
97
|
+
"spec/cream/configure/rails_spec.rb",
|
97
98
|
"spec/cream/helper/host_spec.rb",
|
98
99
|
"spec/cream/helper/role_spec.rb",
|
99
100
|
"spec/cream/view/host_area_spec.rb",
|
100
101
|
"spec/cream/view/role_area_spec.rb",
|
101
|
-
"spec/cream/view/role_ext_spec.rb",
|
102
102
|
"spec/generator_spec_helper.rb",
|
103
103
|
"spec/generators/cream/config/devise/existing_devise_users.rb",
|
104
104
|
"spec/generators/cream/config/empty_app/default_args_spec.rb",
|
@@ -121,9 +121,9 @@ Gem::Specification.new do |s|
|
|
121
121
|
s.add_development_dependency(%q<rspec-action_view>, ["~> 0.3.1"])
|
122
122
|
s.add_development_dependency(%q<rails-app-spec>, ["~> 0.2.14"])
|
123
123
|
s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
|
124
|
-
s.add_runtime_dependency(%q<devise-links>, ["~> 0.1.
|
125
|
-
s.add_runtime_dependency(%q<cancan-rest-links>, ["~> 0.1.
|
126
|
-
s.add_runtime_dependency(%q<cancan-permits>, ["~> 0.1.
|
124
|
+
s.add_runtime_dependency(%q<devise-links>, ["~> 0.1.2"])
|
125
|
+
s.add_runtime_dependency(%q<cancan-rest-links>, ["~> 0.1.2"])
|
126
|
+
s.add_runtime_dependency(%q<cancan-permits>, ["~> 0.1.3"])
|
127
127
|
s.add_runtime_dependency(%q<devise>, [">= 1.1.2"])
|
128
128
|
s.add_runtime_dependency(%q<cancan>, ["~> 1.3.4"])
|
129
129
|
s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
|
@@ -137,9 +137,9 @@ Gem::Specification.new do |s|
|
|
137
137
|
s.add_dependency(%q<rspec-action_view>, ["~> 0.3.1"])
|
138
138
|
s.add_dependency(%q<rails-app-spec>, ["~> 0.2.14"])
|
139
139
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
140
|
-
s.add_dependency(%q<devise-links>, ["~> 0.1.
|
141
|
-
s.add_dependency(%q<cancan-rest-links>, ["~> 0.1.
|
142
|
-
s.add_dependency(%q<cancan-permits>, ["~> 0.1.
|
140
|
+
s.add_dependency(%q<devise-links>, ["~> 0.1.2"])
|
141
|
+
s.add_dependency(%q<cancan-rest-links>, ["~> 0.1.2"])
|
142
|
+
s.add_dependency(%q<cancan-permits>, ["~> 0.1.3"])
|
143
143
|
s.add_dependency(%q<devise>, [">= 1.1.2"])
|
144
144
|
s.add_dependency(%q<cancan>, ["~> 1.3.4"])
|
145
145
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
@@ -154,9 +154,9 @@ Gem::Specification.new do |s|
|
|
154
154
|
s.add_dependency(%q<rspec-action_view>, ["~> 0.3.1"])
|
155
155
|
s.add_dependency(%q<rails-app-spec>, ["~> 0.2.14"])
|
156
156
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
157
|
-
s.add_dependency(%q<devise-links>, ["~> 0.1.
|
158
|
-
s.add_dependency(%q<cancan-rest-links>, ["~> 0.1.
|
159
|
-
s.add_dependency(%q<cancan-permits>, ["~> 0.1.
|
157
|
+
s.add_dependency(%q<devise-links>, ["~> 0.1.2"])
|
158
|
+
s.add_dependency(%q<cancan-rest-links>, ["~> 0.1.2"])
|
159
|
+
s.add_dependency(%q<cancan-permits>, ["~> 0.1.3"])
|
160
160
|
s.add_dependency(%q<devise>, [">= 1.1.2"])
|
161
161
|
s.add_dependency(%q<cancan>, ["~> 1.3.4"])
|
162
162
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
@@ -12,7 +12,7 @@ Rails3::Plugin::Extender.new do
|
|
12
12
|
|
13
13
|
# extend action_view with methods from some modules
|
14
14
|
extend_rails :view do
|
15
|
-
extend_from_module Cream::View, :role, :user_action_menu
|
15
|
+
extend_from_module Cream::View, :role, :host, :user_action_menu
|
16
16
|
extend_from_module Cream::Helper, :role
|
17
17
|
end
|
18
18
|
|
data/lib/cream/role.rb
CHANGED
data/lib/cream/view/role_area.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'r3_plugin_toolbox'
|
3
|
+
require 'cream'
|
4
|
+
require 'action_controller'
|
5
|
+
require 'action_view'
|
6
|
+
require 'active_support/railtie'
|
7
|
+
|
8
|
+
module Minimal
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.active_support.deprecation = :log
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.mock_with :mocha
|
16
|
+
end
|
17
|
+
|
@@ -1,16 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'r3_plugin_toolbox'
|
3
|
-
|
4
|
-
require 'active_support'
|
5
|
-
require 'action_controller'
|
6
|
-
require 'action_view'
|
7
|
-
require 'active_support/railtie'
|
8
|
-
|
9
|
-
module Minimal
|
10
|
-
class Application < Rails::Application
|
11
|
-
config.active_support.deprecation = :log
|
12
|
-
end
|
13
|
-
end
|
1
|
+
require 'configure_helper'
|
14
2
|
|
15
3
|
class Role
|
16
4
|
attr_accessor :name
|
@@ -27,25 +15,20 @@ end
|
|
27
15
|
require 'cream/role'
|
28
16
|
require 'cream/configure'
|
29
17
|
|
30
|
-
Rails.application = Minimal::Application
|
31
|
-
|
32
|
-
Minimal::Application.initialize!
|
33
|
-
|
34
18
|
describe "Rails extension" do
|
35
19
|
describe 'View extension' do
|
36
20
|
it "should extend Action View with Roles helper instance_methods and specific role methods" do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
21
|
+
after_init :view do
|
22
|
+
:view.should be_extended_with Cream::View, :role, :host, :user_action_menu
|
23
|
+
:view.should be_extended_with Cream::Helper, :role
|
24
|
+
# [:admin, :guest].each do |role|
|
25
|
+
# view.should respond_to? :"for_#{role}"
|
26
|
+
# view.should respond_to? :"#{role}_area"
|
27
|
+
# view.should respond_to? :"#{role}?"
|
28
|
+
# end
|
46
29
|
end
|
47
30
|
|
48
|
-
|
49
|
-
end
|
31
|
+
init_app_railties :minimal, :view
|
32
|
+
end
|
50
33
|
end
|
51
|
-
end
|
34
|
+
end
|
@@ -8,27 +8,27 @@ describe Cream::Helper::Role do
|
|
8
8
|
context 'method auto-generated when Rails initialize based on registered roles' do
|
9
9
|
describe '#guest_area' do
|
10
10
|
|
11
|
-
it "should execute an Admin guarded block for :admin" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not execute an Admin guarded block for user not :admin" do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
11
|
+
# it "should execute an Admin guarded block for :admin" do
|
12
|
+
# with_engine do |e, view|
|
13
|
+
# view.stubs(:has_role?).with([:admin]).returns true
|
14
|
+
#
|
15
|
+
# res = e.run_template do
|
16
|
+
# %{<%= for_admin { 'hello' } %>}
|
17
|
+
# end
|
18
|
+
# res.should match /hello/
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# it "should not execute an Admin guarded block for user not :admin" do
|
23
|
+
# with_engine do |e, view|
|
24
|
+
# view.stubs(:has_role?).with([:admin]).returns false
|
25
|
+
#
|
26
|
+
# res = e.run_template do
|
27
|
+
# %{<%= for_admin { 'hello' } %>}
|
28
|
+
# end
|
29
|
+
# res.should be_empty
|
30
|
+
# end
|
31
|
+
# end
|
32
32
|
end # desc
|
33
33
|
end # context
|
34
34
|
|
@@ -8,6 +8,7 @@ require 'cream/view/host_area'
|
|
8
8
|
|
9
9
|
describe Cream::View::Role do
|
10
10
|
extend_view_with Cream::View, :role, :host
|
11
|
+
extend_view_with Cream::Helper, :role
|
11
12
|
|
12
13
|
describe '#area' do
|
13
14
|
it "should display the div with hello" do
|
@@ -81,44 +82,51 @@ describe Cream::View::Role do
|
|
81
82
|
|
82
83
|
describe '#area_not_for_roles' do
|
83
84
|
it "should not display an area for user :admin" do
|
84
|
-
|
85
|
+
with_engine do |e, view|
|
85
86
|
view.stubs(:has_role?).with([:admin]).returns true
|
86
|
-
|
87
|
+
res = e.run_template do
|
88
|
+
%{<%= area_not_for_roles(:admin) { 'hello' } %>}
|
89
|
+
end
|
90
|
+
res.should be_empty
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
94
|
it "should display an area for user not :admin" do
|
91
|
-
|
95
|
+
with_engine do |e, view|
|
92
96
|
# he is not admin
|
93
97
|
view.stubs(:has_role?).with([:admin]).returns false
|
94
|
-
|
98
|
+
|
99
|
+
res = e.run_template do
|
100
|
+
%{<%= area_not_for_roles(:admin) { 'hello' } %>}
|
101
|
+
end
|
102
|
+
res.should match /hello/
|
95
103
|
end
|
96
104
|
end
|
97
105
|
end # desc
|
98
106
|
|
99
|
-
context 'method auto-generated when Rails initialize based on registered roles'
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end # context
|
107
|
+
# context 'method auto-generated when Rails initialize based on registered roles' do
|
108
|
+
# describe '#guest_area' do
|
109
|
+
# it "should display an Admin area for :admin" do
|
110
|
+
# with_engine do |e, view|
|
111
|
+
# view.stubs(:has_role?).with([:admin]).returns true
|
112
|
+
#
|
113
|
+
# res = e.run_template do
|
114
|
+
# %{<%= admin_area { 'hello' } %>}
|
115
|
+
# end
|
116
|
+
# res.should match /hello/
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# it "should not display a Admin area for user not :admin" do
|
121
|
+
# with_engine do |e, view|
|
122
|
+
# view.stubs(:has_role?).with([:admin]).returns false
|
123
|
+
#
|
124
|
+
# res = e.run_template do
|
125
|
+
# %{<%= admin_area { 'hello' } %>}
|
126
|
+
# end
|
127
|
+
# res.should be_empty
|
128
|
+
# end
|
129
|
+
# end
|
130
|
+
# end # desc
|
131
|
+
# end # context
|
124
132
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 8
|
9
|
+
version: 0.5.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -105,8 +105,8 @@ dependencies:
|
|
105
105
|
segments:
|
106
106
|
- 0
|
107
107
|
- 1
|
108
|
-
-
|
109
|
-
version: 0.1.
|
108
|
+
- 2
|
109
|
+
version: 0.1.2
|
110
110
|
type: :runtime
|
111
111
|
version_requirements: *id006
|
112
112
|
- !ruby/object:Gem::Dependency
|
@@ -120,8 +120,8 @@ dependencies:
|
|
120
120
|
segments:
|
121
121
|
- 0
|
122
122
|
- 1
|
123
|
-
-
|
124
|
-
version: 0.1.
|
123
|
+
- 2
|
124
|
+
version: 0.1.2
|
125
125
|
type: :runtime
|
126
126
|
version_requirements: *id007
|
127
127
|
- !ruby/object:Gem::Dependency
|
@@ -135,8 +135,8 @@ dependencies:
|
|
135
135
|
segments:
|
136
136
|
- 0
|
137
137
|
- 1
|
138
|
-
-
|
139
|
-
version: 0.1.
|
138
|
+
- 3
|
139
|
+
version: 0.1.3
|
140
140
|
type: :runtime
|
141
141
|
version_requirements: *id008
|
142
142
|
- !ruby/object:Gem::Dependency
|
@@ -299,12 +299,12 @@ files:
|
|
299
299
|
- lib/generators/cream_refactor.rb
|
300
300
|
- log/development.log
|
301
301
|
- sandbox/test.rb
|
302
|
+
- spec/configure_helper.rb
|
302
303
|
- spec/cream/configure/rails_spec.rb
|
303
304
|
- spec/cream/helper/host_spec.rb
|
304
305
|
- spec/cream/helper/role_spec.rb
|
305
306
|
- spec/cream/view/host_area_spec.rb
|
306
307
|
- spec/cream/view/role_area_spec.rb
|
307
|
-
- spec/cream/view/role_ext_spec.rb
|
308
308
|
- spec/generator_spec_helper.rb
|
309
309
|
- spec/generators/cream/config/devise/existing_devise_users.rb
|
310
310
|
- spec/generators/cream/config/empty_app/default_args_spec.rb
|
@@ -356,12 +356,12 @@ signing_key:
|
|
356
356
|
specification_version: 3
|
357
357
|
summary: Integrates Devise, Roles and CanCan with Permits for a Rails 3 app
|
358
358
|
test_files:
|
359
|
+
- spec/configure_helper.rb
|
359
360
|
- spec/cream/configure/rails_spec.rb
|
360
361
|
- spec/cream/helper/host_spec.rb
|
361
362
|
- spec/cream/helper/role_spec.rb
|
362
363
|
- spec/cream/view/host_area_spec.rb
|
363
364
|
- spec/cream/view/role_area_spec.rb
|
364
|
-
- spec/cream/view/role_ext_spec.rb
|
365
365
|
- spec/generator_spec_helper.rb
|
366
366
|
- spec/generators/cream/config/devise/existing_devise_users.rb
|
367
367
|
- spec/generators/cream/config/empty_app/default_args_spec.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'active_support'
|
4
|
-
require 'action_controller'
|
5
|
-
require 'action_view'
|
6
|
-
# require 'active_record'
|
7
|
-
# require 'action_mailer'
|
8
|
-
require 'active_support/railtie'
|
9
|
-
# require 'rails/all'
|
10
|
-
|
11
|
-
module Minimal
|
12
|
-
class Application < Rails::Application
|
13
|
-
config.active_support.deprecation = :log
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Rails.application = Minimal::Application
|
18
|
-
|
19
|
-
class User
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "View extensions" do
|
23
|
-
describe 'Role area functionality' do
|
24
|
-
|
25
|
-
it "should extend Action View with various Roles helper methods" do
|
26
|
-
after_init :view do
|
27
|
-
:view.should be_extended_with AuthAssistant::View, :roles
|
28
|
-
:view.should be_extended_with AuthAssistant::Helper, :role
|
29
|
-
end
|
30
|
-
|
31
|
-
User.stubs(:roles).returns [:admin, :guest]
|
32
|
-
|
33
|
-
init_app_railties :minimal, :view
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|