cream 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,11 +16,11 @@ RSpec.configure do |config|
16
16
  config.mock_with :mocha
17
17
 
18
18
  config.before do
19
- create_rails_app
19
+ # create_rails_app
20
20
  end
21
21
 
22
- config.after do
23
- remove_rails_app
24
- end
22
+ # config.after do
23
+ # remove_rails_app
24
+ # end
25
25
  end
26
26
 
@@ -0,0 +1,36 @@
1
+ require 'generator_spec_helper'
2
+ require_generator :cancan => :config
3
+
4
+ LOGFILE = 'cancan_config.log'
5
+
6
+ describe 'Generator' do
7
+ use_helpers :controller, :special, :app, :directory, :file
8
+
9
+ before :each do
10
+ setup_generator 'config_generator' do
11
+ tests CanCan::Generators::ConfigGenerator
12
+ end
13
+ end
14
+
15
+ describe "Configure Rails 3 app for use with CanCan" do
16
+ before do
17
+ Dir.chdir Rails.root do
18
+ @generator = with_generator do |g|
19
+ arguments = "--logfile #{LOGFILE}".args
20
+ g.run_generator arguments
21
+ end
22
+ end
23
+ end
24
+
25
+ it "should add cancan gems" do
26
+ Rails.root.should have_gems 'cancan', 'cancan-rest-links'
27
+ end
28
+
29
+ it "should add CanCan rescue clause to ApplicationController" do
30
+ Rails.root.should have_controller :application do |app_controller|
31
+ puts app_controller
32
+ app_controller.should match /rescue_from CanCan::AccessDenied/
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Generator' do
4
+ with_generator do |g, c|
5
+ g.tests Cream::Generators::AppGenerator
6
+ c.setup
7
+ end
8
+
9
+ def check_generated_views folder=nil
10
+ with_generator do |g, check|
11
+ if folder
12
+ g.run_generator folder
13
+ else
14
+ g.run_generator
15
+ folder = 'menu'
16
+ end
17
+ check.view folder, '_admin_login_items.html.erb', %w{admin_block not_admin_block}
18
+ check.view folder, '_login_items.html.erb', %w{user_block not_user_block}
19
+ check.view folder, 'registration_items.html.erb', %w{user_block not_user_block}
20
+ end
21
+ end
22
+
23
+ it "should create views in default scope 'menu' " do
24
+ check_generated_views
25
+ end
26
+
27
+ it "should create views in explicit scope 'login' " do
28
+ check_generated_views 'login'
29
+ end
30
+ end
@@ -0,0 +1,48 @@
1
+ require 'generator_spec_helper'
2
+ require_generator :devise => :config
3
+
4
+ LOGFILE = 'devise-config.log'
5
+
6
+ describe 'Generator' do
7
+ use_helpers :controller, :special, :app, :file
8
+
9
+ before do
10
+ setup_generator :devise_config_generator do
11
+ tests Devise::Generators::ConfigGenerator
12
+ end
13
+ end
14
+
15
+ describe "Configure Rails 3 app for use with Devise" do
16
+
17
+ before do
18
+ orm = :mongoid
19
+
20
+ Dir.chdir Rails.root do
21
+ @generator = with_generator do |g|
22
+ arguments = "--orm #{orm} --logfile #{LOGFILE}".args
23
+ g.run_generator arguments
24
+ end
25
+ end
26
+ end
27
+
28
+ describe 'result of Devise config generator' do
29
+ it "should add devise gems" do
30
+ Rails.root.should have_gem 'devise'
31
+ end
32
+
33
+ it "should add Devise before_filter to ApplicationController" do
34
+ Rails.root.should have_controller :application do |app_controller|
35
+ app_controller.should match /before_filter :authenticate_user!/
36
+ end
37
+ end
38
+
39
+ it "should add orm setting to devise initializer" do
40
+ File.read(initializer_file(:devise)).should match /devise\/orm\/mongoid/
41
+ end
42
+
43
+ it "should add devise mailer setting to Applicaiton config" do
44
+ File.read(application_file).should match /action_mailer.default_url_options/
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,44 @@
1
+ require 'generator_spec_helper'
2
+ require_generator :devise => :users
3
+
4
+ LOGFILE = 'devise-users.log'
5
+
6
+ describe 'Generator' do
7
+ use_orm :active_record
8
+ use_helpers :controller, :special, :app, :file
9
+
10
+ before do
11
+ setup_generator :devise_users_generator do
12
+ tests Devise::Generators::UsersGenerator
13
+ end
14
+ end
15
+
16
+ describe "Configure Rails 3 app with Devise Users" do
17
+
18
+ before do
19
+ orm = :active_record
20
+
21
+ Dir.chdir Rails.root do
22
+ @generator = with_generator do |g|
23
+ arguments = "--admin-user --orm #{orm} --logfile #{LOGFILE}".args
24
+ g.run_generator arguments
25
+ end
26
+ end
27
+ end
28
+
29
+ describe 'result of Devise users generator' do
30
+ it "should create Devise user model User" do
31
+ Rails.root.should have_model :user do |user_model|
32
+ user_model.should match /:database_authenticatable/
33
+ end
34
+ end
35
+
36
+ it "should create Devise user model Admin" do
37
+ Rails.root.should have_model_file :admin do |admin_model|
38
+ admin_model.should inherit_from :user
39
+ admin_model.should have_default_devise_options
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,38 @@
1
+ require 'generator_spec_helper'
2
+ require_generator :permits => :config
3
+
4
+ LOGFILE = 'permits-config.log'
5
+
6
+ describe 'Generator' do
7
+ use_helpers :controller, :special, :file
8
+
9
+ before :each do
10
+ setup_generator :permits_config_generator do
11
+ tests Permits::Generators::ConfigGenerator
12
+ end
13
+ end
14
+
15
+ describe "Configure Rails 3 app for use with CanCan Permits" do
16
+ before do
17
+ puts "Running generator"
18
+ Dir.chdir Rails.root do
19
+ @generator = with_generator do |g|
20
+ arguments = "--orm mongoid --logfile #{LOGFILE}".args
21
+ g.run_generator arguments
22
+ end
23
+ end
24
+ end
25
+
26
+ describe 'result of permits generator' do
27
+
28
+ it "should add the gem :cancan-permits" do
29
+ # TODO
30
+ Rails.root.should have_gem 'cancan-permits'
31
+ end
32
+
33
+ it "should generate a permits initializer file with orm set to mongoid" do
34
+ File.read(initializer_file(:permits)).should match /Permits::Application.orm = mongoid/
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,60 @@
1
+ require 'generator_spec_helper'
2
+ require_generator :roles => :config
3
+
4
+ LOGFILE = 'roles-config.log'
5
+
6
+ describe 'Generator' do
7
+ use_orm :mongoid
8
+ use_helpers :controller, :special, :file
9
+
10
+ before :each do
11
+ setup_generator :roles_config_generator do
12
+ tests Roles::Generators::ConfigGenerator
13
+ end
14
+ end
15
+
16
+ describe "Configure Rails 3 app for use with Roles" do
17
+ before do
18
+ puts "Creating User model"
19
+
20
+ create_model :user do
21
+ '# user model'
22
+ end
23
+
24
+ create_initializer :cream do
25
+ %q{
26
+ Cream.setup do
27
+ roles = :guest, :admin
28
+ end
29
+ }
30
+ end
31
+
32
+ puts "Running generator"
33
+ Dir.chdir Rails.root do
34
+ @generator = with_generator do |g|
35
+ arguments = "--roles guest admin --orm mongoid --strategy admin_flag --logfile #{LOGFILE}".args
36
+ puts "arguments: #{arguments}"
37
+ g.run_generator arguments
38
+ end
39
+ end
40
+ end
41
+
42
+ describe 'result of roles generator' do
43
+ it "should have :roles_mongoid gem" do
44
+ Rails.root.should have_gem 'roles_mongoid'
45
+ end
46
+
47
+ it "should set valid roles for the User model" do
48
+ Rails.root.should have_model :user do |user_model|
49
+ user_model.should match /valid_roles_are Cream.roles/
50
+ end
51
+ end
52
+
53
+ # it "should use the admin_flag roles strategy" do
54
+ # Rails.root.should have_model :user do |user_model|
55
+ # user_model.should match /use_roles_strategy :admin_flag/
56
+ # end
57
+ # end
58
+ end
59
+ end
60
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
8
- - 4
9
- version: 0.6.4
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-07 00:00:00 +02:00
17
+ date: 2010-10-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -119,8 +119,8 @@ dependencies:
119
119
  segments:
120
120
  - 0
121
121
  - 1
122
- - 3
123
- version: 0.1.3
122
+ - 4
123
+ version: 0.1.4
124
124
  type: :runtime
125
125
  version_requirements: *id007
126
126
  - !ruby/object:Gem::Dependency
@@ -133,9 +133,9 @@ dependencies:
133
133
  - !ruby/object:Gem::Version
134
134
  segments:
135
135
  - 0
136
- - 1
137
- - 3
138
- version: 0.1.3
136
+ - 2
137
+ - 4
138
+ version: 0.2.4
139
139
  type: :runtime
140
140
  version_requirements: *id008
141
141
  - !ruby/object:Gem::Dependency
@@ -163,9 +163,9 @@ dependencies:
163
163
  - !ruby/object:Gem::Version
164
164
  segments:
165
165
  - 1
166
- - 3
167
166
  - 4
168
- version: 1.3.4
167
+ - 0
168
+ version: 1.4.0
169
169
  type: :runtime
170
170
  version_requirements: *id010
171
171
  - !ruby/object:Gem::Dependency
@@ -253,6 +253,7 @@ extra_rdoc_files:
253
253
  - LICENSE
254
254
  - README.markdown
255
255
  files:
256
+ - .bundle/config
256
257
  - .document
257
258
  - .gitignore
258
259
  - .rspec
@@ -286,6 +287,8 @@ files:
286
287
  - lib/cream/view/host_area.rb
287
288
  - lib/cream/view/role_area.rb
288
289
  - lib/cream/view/user_action_menu.rb
290
+ - lib/generators/cancan/config/config_generator.rb
291
+ - lib/generators/cream/app/app_generator.rb
289
292
  - lib/generators/cream/config/DESIGN NOTES.markdown
290
293
  - lib/generators/cream/config/config_generator.rb
291
294
  - lib/generators/cream/config/modules/app_config.rb
@@ -299,6 +302,10 @@ files:
299
302
  - lib/generators/cream/views/haml_util.rb
300
303
  - lib/generators/cream/views/views_generator.rb
301
304
  - lib/generators/cream_refactor.rb
305
+ - lib/generators/devise/config/config_generator.rb
306
+ - lib/generators/devise/users/users_generator.rb
307
+ - lib/generators/permits/config/config_generator.rb
308
+ - lib/generators/roles/config/config_generator.rb
302
309
  - log/development.log
303
310
  - sandbox/test.rb
304
311
  - spec/configure_helper.rb
@@ -311,6 +318,8 @@ files:
311
318
  - spec/cream/view/host_area_spec.rb
312
319
  - spec/cream/view/role_area_spec.rb
313
320
  - spec/generator_spec_helper.rb
321
+ - spec/generators/cancan/config/cancan_config_generator_spec.rb
322
+ - spec/generators/cream/app/app_generator_spec.rb
314
323
  - spec/generators/cream/config/CONFIG_GENERATOR_SPEC.markdown
315
324
  - spec/generators/cream/config/devise/existing_devise_users.rb
316
325
  - spec/generators/cream/config/empty_app/default_args_spec.rb
@@ -320,6 +329,10 @@ files:
320
329
  - spec/generators/cream/config/roles/roles_spec.rb
321
330
  - spec/generators/cream/shared_examples.rb
322
331
  - spec/generators/cream/views_generator_spec.rb
332
+ - spec/generators/devise/config/devise_config_generator_spec.rb
333
+ - spec/generators/devise/users/devise_users_generator_spec.rb
334
+ - spec/generators/permits/config/permits_config_generator_spec.rb
335
+ - spec/generators/roles/config/roles_config_generator_spec.rb
323
336
  - spec/spec_helper.rb
324
337
  - wiki/CONFIG_GENERATOR.txt
325
338
  - wiki/DESIGN.txt
@@ -372,6 +385,8 @@ test_files:
372
385
  - spec/cream/view/host_area_spec.rb
373
386
  - spec/cream/view/role_area_spec.rb
374
387
  - spec/generator_spec_helper.rb
388
+ - spec/generators/cancan/config/cancan_config_generator_spec.rb
389
+ - spec/generators/cream/app/app_generator_spec.rb
375
390
  - spec/generators/cream/config/devise/existing_devise_users.rb
376
391
  - spec/generators/cream/config/empty_app/default_args_spec.rb
377
392
  - spec/generators/cream/config/permits/existing_permits_spec.rb
@@ -380,4 +395,8 @@ test_files:
380
395
  - spec/generators/cream/config/roles/roles_spec.rb
381
396
  - spec/generators/cream/shared_examples.rb
382
397
  - spec/generators/cream/views_generator_spec.rb
398
+ - spec/generators/devise/config/devise_config_generator_spec.rb
399
+ - spec/generators/devise/users/devise_users_generator_spec.rb
400
+ - spec/generators/permits/config/permits_config_generator_spec.rb
401
+ - spec/generators/roles/config/roles_config_generator_spec.rb
383
402
  - spec/spec_helper.rb