Permalink
Browse files

removed --dynamic_shortcuts argument from the generator

to use dynamic shortcuts feature when you're using ActiveRecord, you have to enable it _after_ running rake db:migrate as it relies on the roles table
fixes #71
fixes #76
  • Loading branch information...
1 parent 4088b0f commit 5756d4d09ea5ac2925d52277d4affd7578f655a8 @EppO EppO committed Jun 13, 2012
@@ -9,7 +9,7 @@ class RoleGenerator < Rails::Generators::Base
argument :role_cname, :type => :string, :default => "Role"
argument :user_cname, :type => :string, :default => "User"
argument :orm_adapter, :type => :string, :default => "active_record"
- class_option :dynamic_shortcuts, :type => :boolean, :default => false
+ #class_option :dynamic_shortcuts, :type => :boolean, :default => false
desc "Generates a model with the given NAME and a migration file."
@@ -3,5 +3,6 @@
<%= "# " if orm_adapter == "active_record" %>config.use_mongoid
# Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
- <%= "# " if !options[:dynamic_shortcuts] %>config.use_dynamic_shortcuts
+ # Enable this feature _after_ running rake db:migrate as it relies on the roles table
+ # config.use_dynamic_shortcuts
end
@@ -103,48 +103,6 @@ def cleanup_destination_root
end
end
- describe 'specifying dynamic shortcuts' do
- before(:all) { arguments [ "Role", "User", "--dynamic_shortcuts" ] }
-
- before {
- capture(:stdout) {
- generator.create_file "app/models/user.rb" do
- "class User < ActiveRecord::Base\nend"
- end
- }
- run_generator
- }
-
- describe 'config/initializers/rolify.rb' do
- subject { file('config/initializers/rolify.rb') }
- it { should exist }
- it { should contain "Rolify.configure do |config|"}
- it { should_not contain "# config.use_dynamic_shortcuts" }
- it { should contain "# config.use_mongoid" }
- end
-
- describe 'app/models/role.rb' do
- subject { file('app/models/role.rb') }
- it { should exist }
- it { should contain "class Role < ActiveRecord::Base" }
- it { should contain "has_and_belongs_to_many :users, :join_table => :users_roles" }
- it { should contain "belongs_to :resource, :polymorphic => true" }
- end
-
- describe 'app/models/user.rb' do
- subject { file('app/models/user.rb') }
- it { should contain "rolify" }
- end
-
- describe 'migration file' do
- subject { migration_file('db/migrate/rolify_create_roles.rb') }
-
- it { should be_a_migration }
- it { should contain "create_table(:roles) do" }
- it { should contain "create_table(:users_roles, :id => false) do" }
- end
- end
-
describe 'specifying orm adapter' do
before(:all) { arguments [ "Role", "User", "mongoid" ] }

0 comments on commit 5756d4d

Please sign in to comment.