troles 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +161 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +686 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/config/database.yml +4 -0
- data/development.sqlite3 +0 -0
- data/lib/trole/adapters/active_record/config.rb +23 -0
- data/lib/trole/adapters/active_record/storage.rb +0 -0
- data/lib/trole/adapters/active_record/strategy.rb +0 -0
- data/lib/trole/adapters/active_record.rb +8 -0
- data/lib/trole/adapters/mongoid/config.rb +34 -0
- data/lib/trole/adapters/mongoid/storage.rb +0 -0
- data/lib/trole/adapters/mongoid/strategy.rb +0 -0
- data/lib/trole/adapters/mongoid.rb +0 -0
- data/lib/trole/api/cache.rb +9 -0
- data/lib/trole/api/config.rb +12 -0
- data/lib/trole/api/core.rb +20 -0
- data/lib/trole/api/event.rb +9 -0
- data/lib/trole/api/read.rb +14 -0
- data/lib/trole/api/validation.rb +9 -0
- data/lib/trole/api/write.rb +25 -0
- data/lib/trole/api.rb +41 -0
- data/lib/trole/config.rb +15 -0
- data/lib/trole/macros.rb +5 -0
- data/lib/trole/operations/read.rb +12 -0
- data/lib/trole/operations/write.rb +11 -0
- data/lib/trole/operations.rb +34 -0
- data/lib/trole/storage/base_one.rb +46 -0
- data/lib/trole/storage/bit_one.rb +43 -0
- data/lib/trole/storage/embed_one.rb +36 -0
- data/lib/trole/storage/ref_one.rb +39 -0
- data/lib/trole/storage/string_one.rb +50 -0
- data/lib/trole/storage.rb +14 -0
- data/lib/trole/strategy.rb +35 -0
- data/lib/trole.rb +10 -0
- data/lib/troles/adapters/active_record/Design Notes.textile +4 -0
- data/lib/troles/adapters/active_record/config.rb +51 -0
- data/lib/troles/adapters/active_record/storage/embed_many.rb +8 -0
- data/lib/troles/adapters/active_record/storage.rb +5 -0
- data/lib/troles/adapters/active_record/strategy.rb +11 -0
- data/lib/troles/adapters/active_record.rb +8 -0
- data/lib/troles/adapters/mongoid/Design Notes.textile +3 -0
- data/lib/troles/adapters/mongoid/config.rb +45 -0
- data/lib/troles/adapters/mongoid.rb +8 -0
- data/lib/troles/api/cache.rb +4 -0
- data/lib/troles/api/config.rb +9 -0
- data/lib/troles/api/core.rb +9 -0
- data/lib/troles/api/event.rb +4 -0
- data/lib/troles/api/read.rb +4 -0
- data/lib/troles/api/validation.rb +4 -0
- data/lib/troles/api/write.rb +4 -0
- data/lib/troles/api.rb +40 -0
- data/lib/troles/common/api/cache.rb +12 -0
- data/lib/troles/common/api/config.rb +4 -0
- data/lib/troles/common/api/core.rb +52 -0
- data/lib/troles/common/api/event.rb +39 -0
- data/lib/troles/common/api/read.rb +44 -0
- data/lib/troles/common/api/validation.rb +44 -0
- data/lib/troles/common/api/write.rb +76 -0
- data/lib/troles/common/api.rb +28 -0
- data/lib/troles/common/config/schema.rb +72 -0
- data/lib/troles/common/config/schema_helpers.rb +95 -0
- data/lib/troles/common/config/static_roles.rb +14 -0
- data/lib/troles/common/config/valid_roles.rb +21 -0
- data/lib/troles/common/config.rb +96 -0
- data/lib/troles/common/dependencies.rb +9 -0
- data/lib/troles/common/event_manager.rb +40 -0
- data/lib/troles/common/macros/configuration/base_loader.rb +40 -0
- data/lib/troles/common/macros/configuration/config_loader.rb +19 -0
- data/lib/troles/common/macros/configuration/storage_loader.rb +20 -0
- data/lib/troles/common/macros/configuration/strategy_loader.rb +38 -0
- data/lib/troles/common/macros/configuration.rb +89 -0
- data/lib/troles/common/macros/static_roles.rb +9 -0
- data/lib/troles/common/macros/strategy_options.rb +21 -0
- data/lib/troles/common/macros.rb +38 -0
- data/lib/troles/common/marshaller/bitmask.rb +43 -0
- data/lib/troles/common/marshaller/generic.rb +24 -0
- data/lib/troles/common/marshaller.rb +14 -0
- data/lib/troles/common/operations/read.rb +28 -0
- data/lib/troles/common/operations/write.rb +42 -0
- data/lib/troles/common/operations.rb +33 -0
- data/lib/troles/common/storage.rb +73 -0
- data/lib/troles/common.rb +17 -0
- data/lib/troles/config.rb +15 -0
- data/lib/troles/macros.rb +7 -0
- data/lib/troles/meta.rb +5 -0
- data/lib/troles/operations/read.rb +6 -0
- data/lib/troles/operations/write.rb +6 -0
- data/lib/troles/operations.rb +12 -0
- data/lib/troles/storage/base_many.rb +25 -0
- data/lib/troles/storage/bit_many.rb +56 -0
- data/lib/troles/storage/embed_many.rb +58 -0
- data/lib/troles/storage/ref_many.rb +44 -0
- data/lib/troles/storage/string_many.rb +41 -0
- data/lib/troles/storage.rb +13 -0
- data/lib/troles/strategy.rb +34 -0
- data/lib/troles.rb +11 -0
- data/playbox/old_rake +25 -0
- data/spec/Guide to running specs.textile +16 -0
- data/spec/active_record/migrations/many/bit_many.rb +16 -0
- data/spec/active_record/migrations/many/ref_many.rb +31 -0
- data/spec/active_record/migrations/many/string_many.rb +16 -0
- data/spec/active_record/migrations/one/bit_one.rb +14 -0
- data/spec/active_record/migrations/one/ref_one.rb +20 -0
- data/spec/active_record/migrations/one/string_one.rb +14 -0
- data/spec/active_record/models/ref_many.rb +10 -0
- data/spec/active_record/models/ref_one.rb +10 -0
- data/spec/active_record/models/role.rb +2 -0
- data/spec/active_record/models/user.rb +5 -0
- data/spec/active_record/models.rb +2 -0
- data/spec/active_record/strategies/many/bit_many_spec.rb +41 -0
- data/spec/active_record/strategies/many/ref_many_spec.rb +45 -0
- data/spec/active_record/strategies/many/string_many_spec.rb +39 -0
- data/spec/active_record/strategies/one/bit_one_spec.rb +35 -0
- data/spec/active_record/strategies/one/ref_one_spec.rb +41 -0
- data/spec/active_record/strategies/one/string_one_spec.rb +35 -0
- data/spec/active_record/strategy_helper.rb +4 -0
- data/spec/active_record_helper.rb +50 -0
- data/spec/db/database.yml +4 -0
- data/spec/dummy/Gemfile.lock +108 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/main_controller.rb +16 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/ref_many_user.rb +7 -0
- data/spec/dummy/app/models/ref_one_user.rb +3 -0
- data/spec/dummy/app/models/role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/main/index.html.erb +3 -0
- data/spec/dummy/config/application.rb +54 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +52 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/troles.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/01_create_roles.rb +14 -0
- data/spec/dummy/db/migrate/02_create_ref_many_users.rb +20 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/db/seeds.rb +4 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy_spec_helper.rb +33 -0
- data/spec/factories.rb +8 -0
- data/spec/generic/models/accounts/admin_account.rb +7 -0
- data/spec/generic/models/accounts/blogger_account.rb +7 -0
- data/spec/generic/models/accounts/user_account.rb +7 -0
- data/spec/generic/models/accounts.rb +1 -0
- data/spec/generic/models/base_user.rb +27 -0
- data/spec/generic/models/role.rb +37 -0
- data/spec/generic/models/user.rb +7 -0
- data/spec/generic/models.rb +3 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/integration/troles/Running dummy tests.textile +35 -0
- data/spec/integration/troles/navigation_spec.rb +49 -0
- data/spec/mongoid/models/ref_many.rb +15 -0
- data/spec/mongoid/models/ref_one.rb +15 -0
- data/spec/mongoid/models/role.rb +5 -0
- data/spec/mongoid/models/user.rb +9 -0
- data/spec/mongoid/models.rb +2 -0
- data/spec/mongoid/strategies/many/bit_many_spec.rb +35 -0
- data/spec/mongoid/strategies/many/ref_many_spec.rb +35 -0
- data/spec/mongoid/strategies/many/string_many_spec.rb +30 -0
- data/spec/mongoid/strategies/one/bit_one_spec.rb +26 -0
- data/spec/mongoid/strategies/one/ref_one_spec.rb +31 -0
- data/spec/mongoid/strategies/one/string_one_spec.rb +26 -0
- data/spec/mongoid/strategy_helper.rb +4 -0
- data/spec/mongoid_helper.rb +19 -0
- data/spec/playbox/rspec_examples.rb +381 -0
- data/spec/support/shared_examples.rb +1 -0
- data/spec/trole/Trole Design.textile +4 -0
- data/spec/trole/api/cache_api_spec.rb +2 -0
- data/spec/trole/api/core_api_spec.rb +4 -0
- data/spec/trole/api/event_api.rb +2 -0
- data/spec/trole/api/operations_api_spec.rb +2 -0
- data/spec/trole/api/read_api_spec.rb +5 -0
- data/spec/trole/api/validation_api_spec.rb +2 -0
- data/spec/trole/api/write_api_spec.rb +2 -0
- data/spec/trole/api_spec.rb +60 -0
- data/spec/trole/multi_roles_spec.rb +163 -0
- data/spec/trole/operations/read_spec.rb +18 -0
- data/spec/trole/operations/write_spec.rb +0 -0
- data/spec/trole/playbox/shared_examples.rb +107 -0
- data/spec/trole/strategies/bit_one_spec.rb +22 -0
- data/spec/trole/strategies/embed_one_spec.rb +32 -0
- data/spec/trole/strategies/ref_one_spec.rb +29 -0
- data/spec/trole/strategies/string_one_spec.rb +26 -0
- data/spec/trole/strategy_helper.rb +3 -0
- data/spec/trole/two_roles_spec.rb +76 -0
- data/spec/trole_spec.rb +12 -0
- data/spec/trole_spec_helper.rb +20 -0
- data/spec/troles/api/cache_api_spec.rb +2 -0
- data/spec/troles/api/core_api_spec.rb +4 -0
- data/spec/troles/api/event_api.rb +2 -0
- data/spec/troles/api/read_api_spec.rb +2 -0
- data/spec/troles/api/validation_api_spec.rb +2 -0
- data/spec/troles/api/write_api_spec.rb +2 -0
- data/spec/troles/api_spec.rb +41 -0
- data/spec/troles/common/api/cache_api_spec.rb +31 -0
- data/spec/troles/common/api/config_api.rb +0 -0
- data/spec/troles/common/api/core_api_spec.rb +14 -0
- data/spec/troles/common/api/event_api_spec.rb +9 -0
- data/spec/troles/common/api/operations_api_spec.rb +55 -0
- data/spec/troles/common/api/read_api_spec.rb +23 -0
- data/spec/troles/common/api/validation_api_spec.rb +46 -0
- data/spec/troles/common/api/write_api_spec.rb +81 -0
- data/spec/troles/common/api_spec.rb +101 -0
- data/spec/troles/common/config_spec.rb +11 -0
- data/spec/troles/common/multi_roles_spec.rb +142 -0
- data/spec/troles/marshaller/bitmask_spec.rb +14 -0
- data/spec/troles/operations/read_ops_spec.rb +0 -0
- data/spec/troles/operations/write_ops_spec.rb +0 -0
- data/spec/troles/playbox/shared_examples.rb +68 -0
- data/spec/troles/strategies/bit_many_spec.rb +30 -0
- data/spec/troles/strategies/embed_many_spec.rb +35 -0
- data/spec/troles/strategies/ref_many_spec.rb +36 -0
- data/spec/troles/strategies/string_many_spec.rb +32 -0
- data/spec/troles/strategy_helper.rb +3 -0
- data/spec/troles_spec.rb +10 -0
- data/troles.gemspec +325 -0
- metadata +469 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require "active_record/migrations/many/bit_many"
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateBitMany.up # run migration
|
6
|
+
end
|
7
|
+
|
8
|
+
def migrate_down
|
9
|
+
CreateBitMany.down
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
User.troles_strategy :bit_many do |c|
|
14
|
+
c.valid_roles = [:user, :admin, :blogger, :editor]
|
15
|
+
end.configure!
|
16
|
+
|
17
|
+
module UserSetup
|
18
|
+
def create_no_roles_user
|
19
|
+
Factory.create :user, :name => 'no roles', :troles => 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_user
|
23
|
+
Factory.create :user, :name => 'normal', :troles => 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_admin_user
|
27
|
+
Factory.create :user, :name => 'admin', :troles => 2
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_complex_user
|
31
|
+
Factory.create :user, :name => 'user and admin', :troles => 3
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
require 'troles/common/api_spec' # Common API examples
|
37
|
+
|
38
|
+
describe 'Troles strategy :bit_many' do
|
39
|
+
it_should_behave_like "Common API"
|
40
|
+
# it_should_behave_like "Troles API"
|
41
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require 'active_record/models/ref_many'
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateRefMany.up # run migration
|
6
|
+
Config.add_roles [:user, :admin, :editor, :blogger]
|
7
|
+
end
|
8
|
+
|
9
|
+
def migrate_down
|
10
|
+
CreateRefMany.down
|
11
|
+
end
|
12
|
+
|
13
|
+
User.troles_strategy :ref_many do |c|
|
14
|
+
c.valid_roles = [:user, :admin, :blogger, :editor]
|
15
|
+
end.configure!
|
16
|
+
|
17
|
+
module UserSetup
|
18
|
+
def find_role name
|
19
|
+
Role.where(:name => name.to_sym).first
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_no_roles_user
|
23
|
+
Factory.create :user, :name => 'no roles', :troles => []
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_user
|
27
|
+
Factory.create :user, :name => 'normal', :troles => [ find_role(:user) ]
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_admin_user
|
31
|
+
Factory.create :user, :name => 'admin', :troles => [ find_role(:admin) ]
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_complex_user
|
35
|
+
Factory.create :user, :name => 'user and admin', :troles => [ find_role(:user), find_role(:admin) ]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
require 'troles/common/api_spec' # Common API examples
|
41
|
+
|
42
|
+
describe 'Troles strategy :ref_many' do
|
43
|
+
it_should_behave_like "Common API"
|
44
|
+
# it_should_behave_like "Troles API"
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require "active_record/migrations/many/string_many"
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateStringMany.up # run migration
|
6
|
+
end
|
7
|
+
|
8
|
+
def migrate_down
|
9
|
+
CreateStringMany.down
|
10
|
+
end
|
11
|
+
|
12
|
+
User.troles_strategy :string_many do |c|
|
13
|
+
c.valid_roles = [:user, :admin, :blogger, :editor]
|
14
|
+
end.configure!
|
15
|
+
|
16
|
+
module UserSetup
|
17
|
+
def create_no_roles_user
|
18
|
+
Factory.create :user, :name => 'no roles', :troles => ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_user
|
22
|
+
Factory.create :user, :name => 'normal', :troles => 'user'
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_admin_user
|
26
|
+
Factory.create :user, :name => 'admin', :troles => 'admin'
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_complex_user
|
30
|
+
Factory.create :user, :name => 'user and admin', :troles => 'user,admin'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'troles/common/api_spec' # Common API examples
|
35
|
+
|
36
|
+
describe 'Troles strategy :string_many' do
|
37
|
+
it_should_behave_like "Common API"
|
38
|
+
# it_should_behave_like "Troles API"
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require "active_record/migrations/one/bit_one"
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateBitOne.up # run migration
|
6
|
+
end
|
7
|
+
|
8
|
+
def migrate_down
|
9
|
+
CreateBitOne.down
|
10
|
+
end
|
11
|
+
|
12
|
+
User.troles_strategy :bit_one do |c|
|
13
|
+
c.valid_roles = [:user, :admin]
|
14
|
+
end.configure!
|
15
|
+
|
16
|
+
module UserSetup
|
17
|
+
def create_no_roles_user
|
18
|
+
Factory.create :user, :name => 'no roles', :trole => false
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_user
|
22
|
+
Factory.create :user, :name => 'normal', :trole => false
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_admin_user
|
26
|
+
Factory.create :user, :name => 'admin', :trole => true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'troles/common/api_spec' # Common API examples
|
31
|
+
|
32
|
+
describe 'Troles strategy :bit_one' do
|
33
|
+
it_should_behave_like "Common API"
|
34
|
+
# it_should_behave_like "Troles API"
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require 'active_record/models/ref_one'
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateRefOne.up # run migration
|
6
|
+
Config.add_roles [:user, :admin, :editor, :blogger]
|
7
|
+
end
|
8
|
+
|
9
|
+
def migrate_down
|
10
|
+
CreateRefOne.down
|
11
|
+
end
|
12
|
+
|
13
|
+
User.troles_strategy :ref_one do |c|
|
14
|
+
c.valid_roles = [:user, :admin, :blogger, :editor]
|
15
|
+
end.configure!
|
16
|
+
|
17
|
+
module UserSetup
|
18
|
+
def find_role name
|
19
|
+
Role.where(:name => name.to_sym).first
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_no_roles_user
|
23
|
+
Factory.create :user, :name => 'no roles', :trole => nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_user
|
27
|
+
Factory.create :user, :name => 'normal', :trole => find_role(:user)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_admin_user
|
31
|
+
Factory.create :user, :name => 'admin', :trole => find_role(:admin)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
require 'troles/common/api_spec' # Common API examples
|
37
|
+
|
38
|
+
describe 'Troles strategy :ref_one' do
|
39
|
+
it_should_behave_like "Common API"
|
40
|
+
# it_should_behave_like "Troles API"
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "active_record/strategy_helper"
|
2
|
+
require "active_record/migrations/one/string_one"
|
3
|
+
|
4
|
+
def migrate_up
|
5
|
+
CreateStringOne.up # run migration
|
6
|
+
end
|
7
|
+
|
8
|
+
def migrate_down
|
9
|
+
CreateStringOne.down
|
10
|
+
end
|
11
|
+
|
12
|
+
User.troles_strategy :string_one do |c|
|
13
|
+
c.valid_roles = [:user, :admin, :blogger, :editor]
|
14
|
+
end.configure!
|
15
|
+
|
16
|
+
module UserSetup
|
17
|
+
def create_no_roles_user
|
18
|
+
Factory.create :user, :name => 'no roles', :trole => ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_user
|
22
|
+
Factory.create :user, :name => 'normal', :trole => 'user'
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_admin_user
|
26
|
+
Factory.create :user, :name => 'admin', :trole => 'admin'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'troles/common/api_spec' # Common API examples
|
31
|
+
|
32
|
+
describe 'Troles strategy :string_one' do
|
33
|
+
it_should_behave_like "Common API"
|
34
|
+
# it_should_behave_like "Troles API"
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'troles'
|
2
|
+
require 'trole_spec_helper'
|
3
|
+
require 'active_record'
|
4
|
+
require 'yaml'
|
5
|
+
require 'logger'
|
6
|
+
require 'database_cleaner'
|
7
|
+
require 'require_all'
|
8
|
+
require 'active_record/models'
|
9
|
+
|
10
|
+
Troles::Config.default_orm = :active_record
|
11
|
+
Troles::Config.auto_load = true
|
12
|
+
Troles::Config.log_on = true
|
13
|
+
|
14
|
+
dbconfig_path = File.dirname(__FILE__) + '/db/database.yml'
|
15
|
+
dbfile = File.open(dbconfig_path)
|
16
|
+
dbconfig = YAML::load(dbfile)
|
17
|
+
|
18
|
+
ActiveRecord::Base.establish_connection(dbconfig)
|
19
|
+
ActiveRecord::Base.logger = Logger.new(STDERR)
|
20
|
+
|
21
|
+
DatabaseCleaner.strategy = :truncation
|
22
|
+
|
23
|
+
def migration_folder(name)
|
24
|
+
path = File.dirname(__FILE__) + "/migrations/#{name}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def migrate(name)
|
28
|
+
singularity = (name =~/_many/) ? :many : :one
|
29
|
+
ActiveRecord::Migrator.migrate migration_folder File.join(singularity, name)
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
config.before(:suite) do
|
34
|
+
DatabaseCleaner.strategy = :transaction
|
35
|
+
DatabaseCleaner.clean_with(:truncation)
|
36
|
+
end
|
37
|
+
|
38
|
+
config.before(:each) do
|
39
|
+
DatabaseCleaner.start
|
40
|
+
DatabaseCleaner.drop_tables :users, :roles, :users_roles
|
41
|
+
migrate_up
|
42
|
+
# api_migrate
|
43
|
+
end
|
44
|
+
|
45
|
+
config.after(:each) do
|
46
|
+
DatabaseCleaner.clean
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.1.0.rc1)
|
5
|
+
actionpack (= 3.1.0.rc1)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.0.rc1)
|
8
|
+
activemodel (= 3.1.0.rc1)
|
9
|
+
activesupport (= 3.1.0.rc1)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6.0beta1)
|
13
|
+
rack (~> 1.3.0.beta2)
|
14
|
+
rack-cache (~> 1.0.1)
|
15
|
+
rack-mount (~> 0.8.1)
|
16
|
+
rack-test (~> 0.6.0)
|
17
|
+
sprockets (~> 2.0.0.beta.5)
|
18
|
+
tzinfo (~> 0.3.27)
|
19
|
+
activemodel (3.1.0.rc1)
|
20
|
+
activesupport (= 3.1.0.rc1)
|
21
|
+
bcrypt-ruby (~> 2.1.4)
|
22
|
+
builder (~> 3.0.0)
|
23
|
+
i18n (~> 0.6.0beta1)
|
24
|
+
activerecord (3.1.0.rc1)
|
25
|
+
activemodel (= 3.1.0.rc1)
|
26
|
+
activesupport (= 3.1.0.rc1)
|
27
|
+
arel (~> 2.1.1)
|
28
|
+
tzinfo (~> 0.3.27)
|
29
|
+
activeresource (3.1.0.rc1)
|
30
|
+
activemodel (= 3.1.0.rc1)
|
31
|
+
activesupport (= 3.1.0.rc1)
|
32
|
+
activesupport (3.1.0.rc1)
|
33
|
+
multi_json (~> 1.0)
|
34
|
+
ansi (1.2.5)
|
35
|
+
arel (2.1.1)
|
36
|
+
bcrypt-ruby (2.1.4)
|
37
|
+
builder (3.0.0)
|
38
|
+
coffee-script (2.2.0)
|
39
|
+
coffee-script-source
|
40
|
+
execjs
|
41
|
+
coffee-script-source (1.1.1)
|
42
|
+
erubis (2.7.0)
|
43
|
+
execjs (1.0.0)
|
44
|
+
multi_json (~> 1.0)
|
45
|
+
hike (1.0.0)
|
46
|
+
i18n (0.6.0)
|
47
|
+
jquery-rails (1.0.7)
|
48
|
+
railties (~> 3.0)
|
49
|
+
thor (~> 0.14)
|
50
|
+
mail (2.3.0)
|
51
|
+
i18n (>= 0.4.0)
|
52
|
+
mime-types (~> 1.16)
|
53
|
+
treetop (~> 1.4.8)
|
54
|
+
mime-types (1.16)
|
55
|
+
multi_json (1.0.3)
|
56
|
+
polyglot (0.3.1)
|
57
|
+
rack (1.3.0)
|
58
|
+
rack-cache (1.0.2)
|
59
|
+
rack (>= 0.4)
|
60
|
+
rack-mount (0.8.1)
|
61
|
+
rack (>= 1.0.0)
|
62
|
+
rack-ssl (1.3.2)
|
63
|
+
rack
|
64
|
+
rack-test (0.6.0)
|
65
|
+
rack (>= 1.0)
|
66
|
+
rails (3.1.0.rc1)
|
67
|
+
actionmailer (= 3.1.0.rc1)
|
68
|
+
actionpack (= 3.1.0.rc1)
|
69
|
+
activerecord (= 3.1.0.rc1)
|
70
|
+
activeresource (= 3.1.0.rc1)
|
71
|
+
activesupport (= 3.1.0.rc1)
|
72
|
+
bundler (~> 1.0)
|
73
|
+
railties (= 3.1.0.rc1)
|
74
|
+
railties (3.1.0.rc1)
|
75
|
+
actionpack (= 3.1.0.rc1)
|
76
|
+
activesupport (= 3.1.0.rc1)
|
77
|
+
rack-ssl (~> 1.3.2)
|
78
|
+
rake (>= 0.8.7)
|
79
|
+
thor (~> 0.14.6)
|
80
|
+
rake (0.9.0)
|
81
|
+
sass (3.1.1)
|
82
|
+
sprockets (2.0.0.beta.8)
|
83
|
+
hike (~> 1.0)
|
84
|
+
rack (~> 1.0)
|
85
|
+
tilt (!= 1.3.0, ~> 1.1)
|
86
|
+
sqlite3 (1.3.3)
|
87
|
+
thor (0.14.6)
|
88
|
+
tilt (1.3.1)
|
89
|
+
treetop (1.4.9)
|
90
|
+
polyglot (>= 0.3.1)
|
91
|
+
turn (0.8.2)
|
92
|
+
ansi (>= 1.2.2)
|
93
|
+
tzinfo (0.3.27)
|
94
|
+
uglifier (0.5.4)
|
95
|
+
execjs (>= 0.3.0)
|
96
|
+
multi_json (>= 1.0.2)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
coffee-script
|
103
|
+
jquery-rails
|
104
|
+
rails (= 3.1.0.rc1)
|
105
|
+
sass
|
106
|
+
sqlite3
|
107
|
+
turn
|
108
|
+
uglifier
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class MainController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@users = RefManyUser.all
|
5
|
+
|
6
|
+
first_user = @users.first
|
7
|
+
|
8
|
+
# puts "Clearing roles of first user"
|
9
|
+
first_user.clear_roles!
|
10
|
+
|
11
|
+
# puts "Adding role admin to first user"
|
12
|
+
first_user.roles << :admin
|
13
|
+
|
14
|
+
# puts "#{first_user.name} has role :admin? #{first_user.has_role? :admin}"
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
# require 'trole'
|
11
|
+
require "troles"
|
12
|
+
require 'troles/macros'
|
13
|
+
|
14
|
+
module Dummy
|
15
|
+
class Application < Rails::Application
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
17
|
+
# Application configuration should go into files in config/initializers
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
19
|
+
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Activate observers that should always be running.
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
|
+
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
33
|
+
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
36
|
+
# config.i18n.default_locale = :de
|
37
|
+
|
38
|
+
# Please note that JavaScript expansions are *ignored altogether* if the asset
|
39
|
+
# pipeline is enabled (see config.assets.enabled below). Put your defaults in
|
40
|
+
# app/assets/javascripts/application.js in that case.
|
41
|
+
#
|
42
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
43
|
+
# config.action_view.javascript_expansions[:defaults] = %w(prototype prototype_ujs)
|
44
|
+
|
45
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
46
|
+
config.encoding = "utf-8"
|
47
|
+
|
48
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
49
|
+
config.filter_parameters += [:password]
|
50
|
+
|
51
|
+
# Enable the asset pipeline
|
52
|
+
config.assets.enabled = true
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
end
|