effective_roles 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 411756a3ec04ce4e19ab11eee6446f9ca422f853
4
- data.tar.gz: f1e95599e802a859d71e905f9776b24d5782389a
3
+ metadata.gz: fea6abc1820780d612a22a1c66c180cdc17f1ab6
4
+ data.tar.gz: 37047ba965d662456396b4bd1aa1c7557b655677
5
5
  SHA512:
6
- metadata.gz: 2bc8b3eec999f7a63d8c0b0bcea2121649e564209f794c206a40a617df0164b3404eeda37fa5a0b2a491084b4ab1ad343bd9cf174c8331214b9aaee0d2ed6e2f
7
- data.tar.gz: b110ef8795df8e32c1b98e69f056902edb41b4aa2581ed846730fd6fcfd50769c7daeb854036f68ccf92100b5d5fea1fa1c295ddb70fe30c70158d28ba688987
6
+ metadata.gz: d5214db952f1b44cf46f0d95239e27b938a97a3d27282a3be7a1863f530a1eba9c63d43a7c1f89669e8d42bdead1f57dd231fa59a2e33779b64e8b6db7c5ecc2
7
+ data.tar.gz: 833ae9a7a654221bb1144b289628a8aeb35b2817d39fcee986ea3e9df62a7dd3fe0ed15c69f926e6a2e8173292b2df09228e7ebca9634cd757096c3676d07a19
@@ -3,39 +3,60 @@ require "effective_roles/version"
3
3
 
4
4
  module EffectiveRoles
5
5
  mattr_accessor :roles
6
- mattr_accessor :assignable_roles
7
6
  mattr_accessor :role_descriptions
8
7
 
8
+ mattr_accessor :assignable_roles
9
+ mattr_accessor :disabled_roles
10
+
9
11
  def self.setup
10
12
  yield self
11
13
  end
12
14
 
13
15
  def self.roles_for_roles_mask(roles_mask)
14
- roles_mask = Integer(roles_mask)
15
- EffectiveRoles.roles.reject { |r| (roles_mask & 2**EffectiveRoles.roles.index(r)).zero? }
16
+ roles_mask = Integer(roles_mask || 0)
17
+ roles.reject { |r| (roles_mask & 2**roles.index(r)).zero? }
16
18
  end
17
19
 
18
20
  def self.roles_collection(obj = nil, user = nil)
19
- raise ArgumentError.new('EffectiveRoles config.role_descriptions must be a Hash. The Array syntax is deprecated.') unless EffectiveRoles.role_descriptions.kind_of?(Hash)
20
-
21
- descriptions = role_descriptions[obj.try(:class).to_s] || role_descriptions || {}
22
-
23
21
  assignable_roles_for(user, obj).map do |role|
24
- ["#{role}<br>#{descriptions[role]}".html_safe, role]
22
+ [
23
+ "#{role}<p class='help-block'>#{role_description(role, obj)}</p>".html_safe,
24
+ role,
25
+ ({:disabled => :disabled} if disabled_roles_for(obj).include?(role))
26
+ ]
25
27
  end
26
28
  end
27
29
 
30
+ private
31
+
28
32
  def self.assignable_roles_for(user, obj = nil)
29
- return roles unless user.respond_to?(:is_role_restricted?) # All roles, if the user (or object) is not role_resticted
33
+ raise 'EffectiveRoles config.assignable_roles_for must be a Hash, Array or nil' unless [Hash, Array, NilClass].include?(assignable_roles.class)
34
+
35
+ return assignable_roles if assignable_roles.kind_of?(Array)
36
+ return roles if assignable_roles.nil?
37
+ return roles if !user.respond_to?(:is_role_restricted?) # All roles, if the user (or object) is not role_resticted
30
38
 
31
39
  assignable = assignable_roles[obj.try(:class).to_s] || assignable_roles || {}
32
40
 
33
- if assignable.present?
34
- user.roles.map { |role| assignable[role] }.flatten.compact.uniq
41
+ user.roles.map { |role| assignable[role] }.flatten.compact.uniq
42
+ end
43
+
44
+ def self.role_description(role, obj = nil)
45
+ raise 'EffectiveRoles config.role_descriptions must be a Hash' unless role_descriptions.kind_of?(Hash)
46
+ (role_descriptions[obj.try(:class).to_s] || {})[role] || role_descriptions[role] || ''
47
+ end
48
+
49
+ def self.disabled_roles_for(obj)
50
+ raise 'EffectiveRoles config.disabled_roles must be a Hash, Array or nil' unless [Hash, Array, NilClass].include?(disabled_roles.class)
51
+
52
+ case disabled_roles
53
+ when Array
54
+ disabled_roles
55
+ when Hash
56
+ Array(disabled_roles[obj.try(:class).to_s])
35
57
  else
36
- roles
58
+ []
37
59
  end
38
60
  end
39
61
 
40
-
41
62
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveRoles
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -1,7 +1,35 @@
1
1
  EffectiveRoles.setup do |config|
2
2
  config.roles = [:superadmin, :admin, :member] # Only add to the end of this array. Never prepend roles.
3
3
 
4
+ # config.role_descriptions
5
+ # ========================
6
+ # This setting configures the text that is displayed by form helpers (see README.md)
7
+ #
8
+ # Use this Hash syntax if you want different labels depending on the resource being editted
9
+ #
10
+ # config.role_descriptions = {
11
+ # 'User' => {
12
+ # :superadmin => 'full access to everything. Can manage users and all website content.',
13
+ # :admin => 'full access to website content. Cannot manage users.',
14
+ # :member => 'cannot access admin area. Can see all content in members-only sections of the website.''
15
+ # },
16
+ # 'Effective::Page' => {
17
+ # :superadmin => 'allow superadmins to see this page',
18
+ # :admin => 'allow admins to see this page',
19
+ # :member => 'allow members to see this page'
20
+ # }
21
+ # }
22
+ #
23
+ # Or just keep it simple, and use this Hash syntax of permissions for every resource
24
+ #
25
+ config.role_descriptions = {
26
+ :superadmin => 'full access to everything. Can manage users and all website content.',
27
+ :admin => 'full access to website content. Cannot manage users.',
28
+ :member => 'cannot access admin area. Can see all content in members-only sections of the website.'
29
+ }
30
+
4
31
  # config.assignable_roles
32
+ # Which roles can be assigned by whom
5
33
  # =======================
6
34
  # When current_user is passed into a form helper function (see README.md)
7
35
  # this setting determines which roles that current_user may assign
@@ -28,31 +56,25 @@ EffectiveRoles.setup do |config|
28
56
  :member => [] # Members may not assign any roles
29
57
  }
30
58
 
31
- # config.role_descriptions
32
- # ========================
33
- # This setting configures the text that is displayed by form helpers (see README.md)
59
+ # config.disabled_roles
60
+ # Which roles should be displayed as disabled
61
+ # =========================
62
+ # Sometimes you don't want a role to be assignable (see README.md)
63
+ # So that you can overload it yourself and assingn the role programatically
34
64
  #
35
- # Use this Hash syntax if you want different labels depending on the resource being editted
65
+ # Use this Hash syntax if you want different permissions depending on the resource being editted
36
66
  #
37
- # config.role_descriptions = {
38
- # 'User' => {
39
- # :superadmin => 'full access to everything. Can manage users and all website content.',
40
- # :admin => 'full access to website content. Cannot manage users.',
41
- # :member => 'cannot access admin area. Can see all content in members-only sections of the website.''
42
- # },
43
- # 'Effective::Page' => {
44
- # :superadmin => 'allow superadmins to see this page',
45
- # :admin => 'allow admins to see this page',
46
- # :member => 'allow members to see this page'
47
- # }
67
+ # config.disabled_roles = {
68
+ # 'User' => [:member] # When editing a User object, will be unable to assign the member role
69
+ # 'Page' => [:superadmin, :admin] # When editing a Page object, will be unable to assign superadmin, admin role
48
70
  # }
49
71
  #
50
- # Or just keep it simple, and use this Hash syntax of permissions for every resource
72
+ # Or just keep it simple, and use this Array syntax of permissions for every resource
51
73
  #
52
- config.role_descriptions = {
53
- :superadmin => 'full access to everything. Can manage users and all website content.',
54
- :admin => 'full access to website content. Cannot manage users.',
55
- :member => 'cannot access admin area. Can see all content in members-only sections of the website.'
74
+ # config.unassignable_roles = [:member]
75
+ config.disabled_roles = {
76
+ 'User' => [:member]
56
77
  }
57
78
 
79
+
58
80
  end
@@ -1,261 +1,10 @@
1
- == Welcome to Rails
1
+ == README
2
2
 
3
- Rails is a web-application framework that includes everything needed to create
4
- database-backed web applications according to the Model-View-Control pattern.
3
+ To change the test database in this dummy app:
5
4
 
6
- This pattern splits the view (also called the presentation) into "dumb"
7
- templates that are primarily responsible for inserting pre-built data in between
8
- HTML tags. The model contains the "smart" domain objects (such as Account,
9
- Product, Person, Post) that holds all the business logic and knows how to
10
- persist themselves to a database. The controller handles the incoming requests
11
- (such as Save New Account, Update Product, Show Post) by manipulating the model
12
- and directing data to the view.
5
+ - Delete the existing test.sqlite3
6
+ - No migrations, so just make whatever changes you want to schema.rb
13
7
 
14
- In Rails, the model is handled by what's called an object-relational mapping
15
- layer entitled Active Record. This layer allows you to present the data from
16
- database rows as objects and embellish these data objects with business logic
17
- methods. You can read more about Active Record in
18
- link:files/vendor/rails/activerecord/README.html.
8
+ bundle exec rake app:db:test:prepare
19
9
 
20
- The controller and view are handled by the Action Pack, which handles both
21
- layers by its two parts: Action View and Action Controller. These two layers
22
- are bundled in a single package due to their heavy interdependence. This is
23
- unlike the relationship between the Active Record and Action Pack that is much
24
- more separate. Each of these packages can be used independently outside of
25
- Rails. You can read more about Action Pack in
26
- link:files/vendor/rails/actionpack/README.html.
27
-
28
-
29
- == Getting Started
30
-
31
- 1. At the command prompt, create a new Rails application:
32
- <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
-
34
- 2. Change directory to <tt>myapp</tt> and start the web server:
35
- <tt>cd myapp; rails server</tt> (run with --help for options)
36
-
37
- 3. Go to http://localhost:3000/ and you'll see:
38
- "Welcome aboard: You're riding Ruby on Rails!"
39
-
40
- 4. Follow the guidelines to start developing your application. You can find
41
- the following resources handy:
42
-
43
- * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
- * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
-
46
-
47
- == Debugging Rails
48
-
49
- Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
- will help you debug it and get it back on the rails.
51
-
52
- First area to check is the application log files. Have "tail -f" commands
53
- running on the server.log and development.log. Rails will automatically display
54
- debugging and runtime information to these files. Debugging info will also be
55
- shown in the browser on requests from 127.0.0.1.
56
-
57
- You can also log your own messages directly into the log file from your code
58
- using the Ruby logger class from inside your controllers. Example:
59
-
60
- class WeblogController < ActionController::Base
61
- def destroy
62
- @weblog = Weblog.find(params[:id])
63
- @weblog.destroy
64
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
- end
66
- end
67
-
68
- The result will be a message in your log file along the lines of:
69
-
70
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
-
72
- More information on how to use the logger is at http://www.ruby-doc.org/core/
73
-
74
- Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
- several books available online as well:
76
-
77
- * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
- * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
-
80
- These two books will bring you up to speed on the Ruby language and also on
81
- programming in general.
82
-
83
-
84
- == Debugger
85
-
86
- Debugger support is available through the debugger command when you start your
87
- Mongrel or WEBrick server with --debugger. This means that you can break out of
88
- execution at any point in the code, investigate and change the model, and then,
89
- resume execution! You need to install ruby-debug to run the server in debugging
90
- mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
-
92
- class WeblogController < ActionController::Base
93
- def index
94
- @posts = Post.all
95
- debugger
96
- end
97
- end
98
-
99
- So the controller will accept the action, run the first line, then present you
100
- with a IRB prompt in the server window. Here you can do things like:
101
-
102
- >> @posts.inspect
103
- => "[#<Post:0x14a6be8
104
- @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
- #<Post:0x14a6620
106
- @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
- >> @posts.first.title = "hello from a debugger"
108
- => "hello from a debugger"
109
-
110
- ...and even better, you can examine how your runtime objects actually work:
111
-
112
- >> f = @posts.first
113
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
- >> f.
115
- Display all 152 possibilities? (y or n)
116
-
117
- Finally, when you're ready to resume execution, you can enter "cont".
118
-
119
-
120
- == Console
121
-
122
- The console is a Ruby shell, which allows you to interact with your
123
- application's domain model. Here you'll have all parts of the application
124
- configured, just like it is when the application is running. You can inspect
125
- domain models, change values, and save to the database. Starting the script
126
- without arguments will launch it in the development environment.
127
-
128
- To start the console, run <tt>rails console</tt> from the application
129
- directory.
130
-
131
- Options:
132
-
133
- * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
- made to the database.
135
- * Passing an environment name as an argument will load the corresponding
136
- environment. Example: <tt>rails console production</tt>.
137
-
138
- To reload your controllers and models after launching the console run
139
- <tt>reload!</tt>
140
-
141
- More information about irb can be found at:
142
- link:http://www.rubycentral.org/pickaxe/irb.html
143
-
144
-
145
- == dbconsole
146
-
147
- You can go to the command line of your database directly through <tt>rails
148
- dbconsole</tt>. You would be connected to the database with the credentials
149
- defined in database.yml. Starting the script without arguments will connect you
150
- to the development database. Passing an argument will connect you to a different
151
- database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
- PostgreSQL and SQLite 3.
153
-
154
- == Description of Contents
155
-
156
- The default directory structure of a generated Ruby on Rails application:
157
-
158
- |-- app
159
- | |-- assets
160
- | | |-- images
161
- | | |-- javascripts
162
- | | `-- stylesheets
163
- | |-- controllers
164
- | |-- helpers
165
- | |-- mailers
166
- | |-- models
167
- | `-- views
168
- | `-- layouts
169
- |-- config
170
- | |-- environments
171
- | |-- initializers
172
- | `-- locales
173
- |-- db
174
- |-- doc
175
- |-- lib
176
- | |-- assets
177
- | `-- tasks
178
- |-- log
179
- |-- public
180
- |-- script
181
- |-- test
182
- | |-- fixtures
183
- | |-- functional
184
- | |-- integration
185
- | |-- performance
186
- | `-- unit
187
- |-- tmp
188
- | `-- cache
189
- | `-- assets
190
- `-- vendor
191
- |-- assets
192
- | |-- javascripts
193
- | `-- stylesheets
194
- `-- plugins
195
-
196
- app
197
- Holds all the code that's specific to this particular application.
198
-
199
- app/assets
200
- Contains subdirectories for images, stylesheets, and JavaScript files.
201
-
202
- app/controllers
203
- Holds controllers that should be named like weblogs_controller.rb for
204
- automated URL mapping. All controllers should descend from
205
- ApplicationController which itself descends from ActionController::Base.
206
-
207
- app/models
208
- Holds models that should be named like post.rb. Models descend from
209
- ActiveRecord::Base by default.
210
-
211
- app/views
212
- Holds the template files for the view that should be named like
213
- weblogs/index.html.erb for the WeblogsController#index action. All views use
214
- eRuby syntax by default.
215
-
216
- app/views/layouts
217
- Holds the template files for layouts to be used with views. This models the
218
- common header/footer method of wrapping views. In your views, define a layout
219
- using the <tt>layout :default</tt> and create a file named default.html.erb.
220
- Inside default.html.erb, call <% yield %> to render the view using this
221
- layout.
222
-
223
- app/helpers
224
- Holds view helpers that should be named like weblogs_helper.rb. These are
225
- generated for you automatically when using generators for controllers.
226
- Helpers can be used to wrap functionality for your views into methods.
227
-
228
- config
229
- Configuration files for the Rails environment, the routing map, the database,
230
- and other dependencies.
231
-
232
- db
233
- Contains the database schema in schema.rb. db/migrate contains all the
234
- sequence of Migrations for your schema.
235
-
236
- doc
237
- This directory is where your application documentation will be stored when
238
- generated using <tt>rake doc:app</tt>
239
-
240
- lib
241
- Application specific libraries. Basically, any kind of custom code that
242
- doesn't belong under controllers, models, or helpers. This directory is in
243
- the load path.
244
-
245
- public
246
- The directory available for the web server. Also contains the dispatchers and the
247
- default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
- server.
249
-
250
- script
251
- Helper scripts for automation and generation.
252
-
253
- test
254
- Unit and functional tests along with fixtures. When using the rails generate
255
- command, template test files will be generated for you and placed in this
256
- directory.
257
-
258
- vendor
259
- External libraries that the application depends on. Also includes the plugins
260
- subdirectory. If the app has frozen rails, those gems also go here, under
261
- vendor/rails/. This directory is in the load path.
10
+ RAILS_ENV=test rake db:schema:load; rake
@@ -4,4 +4,4 @@
4
4
 
5
5
  require File.expand_path('../config/application', __FILE__)
6
6
 
7
- Dummy::Application.load_tasks
7
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ class Post < ActiveRecord::Base
2
+ acts_as_role_restricted
3
+ end
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ acts_as_role_restricted
3
+ end
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
3
  require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
4
+ run Rails.application
@@ -47,7 +47,6 @@ module Dummy
47
47
  # This will create an empty whitelist of attributes available for mass-assignment for all models
48
48
  # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
49
  # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
51
50
 
52
51
  # Enable the asset pipeline
53
52
  config.assets.enabled = true
@@ -23,7 +23,6 @@ Dummy::Application.configure do
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
25
  # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
26
 
28
27
  # Log the query plan for queries taking more than this (works
29
28
  # with SQLite, MySQL, and PostgreSQL)
@@ -8,12 +8,13 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
11
  config.static_cache_control = "public, max-age=3600"
13
12
 
14
13
  # Log error messages when you accidentally call methods on nil
15
14
  config.whiny_nils = true
16
15
 
16
+ config.eager_load = false
17
+
17
18
  # Show full error reports and disable caching
18
19
  config.consider_all_requests_local = true
19
20
  config.action_controller.perform_caching = false
@@ -30,7 +31,6 @@ Dummy::Application.configure do
30
31
  config.action_mailer.delivery_method = :test
31
32
 
32
33
  # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
34
 
35
35
  # Print deprecation notices to the stderr
36
36
  config.active_support.deprecation = :stderr
@@ -11,6 +11,36 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 0) do
14
+ ActiveRecord::Schema.define(:version => 1) do
15
+
16
+ create_table "users", force: true do |t|
17
+ t.string "encrypted_password"
18
+ t.string "reset_password_token"
19
+ t.datetime "reset_password_sent_at"
20
+ t.datetime "remember_created_at"
21
+ t.datetime "confirmation_sent_at"
22
+ t.datetime "confirmed_at"
23
+ t.string "confirmation_token"
24
+ t.string "unconfirmed_email"
25
+ t.integer "sign_in_count", default: 0
26
+ t.datetime "current_sign_in_at"
27
+ t.datetime "last_sign_in_at"
28
+ t.string "current_sign_in_ip"
29
+ t.string "last_sign_in_ip"
30
+ t.string "email"
31
+ t.string "first_name"
32
+ t.string "last_name"
33
+ t.integer "roles_mask", default: 0
34
+ t.boolean "archived", default: false
35
+ t.datetime "updated_at"
36
+ t.datetime "created_at"
37
+ end
38
+
39
+ create_table "posts", force: true do |t|
40
+ t.string "title"
41
+ t.integer "roles_mask", default: 0
42
+ t.datetime "updated_at"
43
+ t.datetime "created_at"
44
+ end
15
45
 
16
46
  end
Binary file
@@ -1 +1,92 @@
1
- Connecting to database specified by database.yml
1
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3
+  (3.3ms) DROP TABLE "users"
4
+  (1.1ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "encrypted_password" varchar, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "confirmation_sent_at" datetime, "confirmed_at" datetime, "confirmation_token" varchar, "unconfirmed_email" varchar, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "email" varchar, "first_name" varchar, "last_name" varchar, "roles_mask" integer DEFAULT 0, "archived" boolean DEFAULT 'f', "updated_at" datetime, "created_at" datetime)
5
+  (1.0ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "roles_mask" integer DEFAULT 0, "updated_at" datetime, "created_at" datetime) 
6
+  (0.3ms) SELECT version FROM "schema_migrations"
7
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
8
+  (3.1ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "encrypted_password" varchar, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "confirmation_sent_at" datetime, "confirmed_at" datetime, "confirmation_token" varchar, "unconfirmed_email" varchar, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "email" varchar, "first_name" varchar, "last_name" varchar, "roles_mask" integer DEFAULT 0, "archived" boolean DEFAULT 'f', "updated_at" datetime, "created_at" datetime) 
9
+  (1.2ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "roles_mask" integer DEFAULT 0, "updated_at" datetime, "created_at" datetime)
10
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
11
+  (0.1ms) select sqlite_version(*)
12
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
13
+  (0.1ms) SELECT version FROM "schema_migrations"
14
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('1')
15
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
16
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
17
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
18
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
19
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
20
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
21
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
22
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
23
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
24
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
25
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
26
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
27
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
28
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
29
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
30
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
31
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
32
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
33
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
34
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
35
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
36
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
37
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
38
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
39
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
40
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
41
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
42
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
43
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
44
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
45
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
46
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
47
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
48
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
49
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
50
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
51
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
52
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
53
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
54
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
55
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
56
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
57
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
58
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
59
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
60
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
61
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
62
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
63
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
64
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
65
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
66
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
67
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
68
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
69
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
70
+ ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
71
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
72
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
73
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
74
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
75
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
76
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
77
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
78
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
79
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
80
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
81
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
82
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
83
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
84
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
85
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
86
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
87
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
88
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
89
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
90
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
91
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
92
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -1,7 +1,147 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EffectiveRoles do
4
- it 'should be a module' do
5
- assert_kind_of Module, EffectiveRoles
4
+ let(:roles) { [:superadmin, :admin, :member] }
5
+
6
+ let(:post) { Post.new }
7
+ let(:user) { User.new.tap { |user| user.roles = [] } }
8
+
9
+ let(:member) { User.new.tap { |user| user.roles = [:member] } }
10
+ let(:admin) { User.new.tap { |user| user.roles = [:admin] } }
11
+ let(:superadmin) { User.new.tap { |user| user.roles = [:superadmin] } }
12
+
13
+ before(:each) do
14
+ EffectiveRoles.setup { |config| config.roles = roles }
6
15
  end
16
+
17
+ describe '#roles_for_roles_mask' do
18
+ it 'computes the appropriate roles for the given mask' do
19
+ EffectiveRoles.roles_for_roles_mask(nil).should eq []
20
+ EffectiveRoles.roles_for_roles_mask(0).should eq []
21
+ EffectiveRoles.roles_for_roles_mask(1).should eq [:superadmin]
22
+ EffectiveRoles.roles_for_roles_mask(2).should eq [:admin]
23
+ EffectiveRoles.roles_for_roles_mask(3).should eq [:superadmin, :admin]
24
+ EffectiveRoles.roles_for_roles_mask(4).should eq [:member]
25
+ EffectiveRoles.roles_for_roles_mask(5).should eq [:superadmin, :member]
26
+ EffectiveRoles.roles_for_roles_mask(6).should eq [:admin, :member]
27
+ EffectiveRoles.roles_for_roles_mask(7).should eq [:superadmin, :admin, :member]
28
+ EffectiveRoles.roles_for_roles_mask(8).should eq []
29
+ end
30
+ end
31
+
32
+ describe '#assignable_roles' do
33
+ it 'uses the full Hash syntax to return the appropriate roles based on the passed User' do
34
+ EffectiveRoles.setup do |config|
35
+ config.assignable_roles = {
36
+ 'User' => {
37
+ :superadmin => [:superadmin, :admin, :member], # Superadmins may assign all roles on a User#edit screen
38
+ :admin => [:admin, :member], # Admins may only assign :admin, :member on a User#edit screen
39
+ :member => [] # Members can assign no roles
40
+ },
41
+ 'Post' => {
42
+ :superadmin => [:superadmin], # Superadmins may assign ony superadmin on a Post#edit screen
43
+ :admin => [:superadmin, :admin],
44
+ :member => [:admin, :member]
45
+ }
46
+ }
47
+ end
48
+
49
+ # On a User#edit screen
50
+ EffectiveRoles.assignable_roles_for(nil, user).should eq [:superadmin, :admin, :member]
51
+ EffectiveRoles.assignable_roles_for(superadmin, user).should eq [:superadmin, :admin, :member]
52
+ EffectiveRoles.assignable_roles_for(admin, user).should eq [:admin, :member]
53
+ EffectiveRoles.assignable_roles_for(member, user).should eq []
54
+ EffectiveRoles.assignable_roles_for(user, user).should eq []
55
+
56
+ # On a Post#edit screen
57
+ EffectiveRoles.assignable_roles_for(nil, post).should eq [:superadmin, :admin, :member]
58
+ EffectiveRoles.assignable_roles_for(superadmin, post).should eq [:superadmin]
59
+ EffectiveRoles.assignable_roles_for(admin, post).should eq [:superadmin, :admin]
60
+ EffectiveRoles.assignable_roles_for(member, post).should eq [:admin, :member]
61
+ EffectiveRoles.assignable_roles_for(user, post).should eq []
62
+
63
+ # On an unsupported object #edit screen
64
+ EffectiveRoles.assignable_roles_for(nil, nil).should eq [:superadmin, :admin, :member]
65
+ EffectiveRoles.assignable_roles_for(superadmin, nil).should eq []
66
+ EffectiveRoles.assignable_roles_for(admin, nil).should eq []
67
+ EffectiveRoles.assignable_roles_for(member, nil).should eq []
68
+ EffectiveRoles.assignable_roles_for(user, nil).should eq []
69
+ end
70
+
71
+ it 'uses the simple Hash syntax to return the appropriate roles based on the passed User' do
72
+ EffectiveRoles.setup do |config|
73
+ config.assignable_roles = {
74
+ :superadmin => [:superadmin, :admin, :member], # Superadmins may assign any resource any role
75
+ :admin => [:admin, :member], # Admins may only assign the :admin or :member role
76
+ :member => [] # Members may not assign any roles
77
+ }
78
+ end
79
+
80
+ EffectiveRoles.assignable_roles_for(nil).should eq [:superadmin, :admin, :member]
81
+
82
+ EffectiveRoles.assignable_roles_for(superadmin).should eq [:superadmin, :admin, :member]
83
+ EffectiveRoles.assignable_roles_for(admin).should eq [:admin, :member]
84
+ EffectiveRoles.assignable_roles_for(member).should eq []
85
+ EffectiveRoles.assignable_roles_for(user).should eq []
86
+ end
87
+
88
+ it 'uses the Array syntax to return the appropriate roles based on the passed User' do
89
+ EffectiveRoles.setup do |config|
90
+ config.assignable_roles = [:admin, :member]
91
+ end
92
+
93
+ EffectiveRoles.assignable_roles_for(nil).should eq [:admin, :member]
94
+ EffectiveRoles.assignable_roles_for(superadmin).should eq [:admin, :member]
95
+ EffectiveRoles.assignable_roles_for(admin).should eq [:admin, :member]
96
+ EffectiveRoles.assignable_roles_for(member).should eq [:admin, :member]
97
+ EffectiveRoles.assignable_roles_for(user).should eq [:admin, :member]
98
+ end
99
+
100
+ it 'uses the Nil syntax to return all roles regardless of User' do
101
+ EffectiveRoles.setup do |config|
102
+ config.assignable_roles = nil
103
+ end
104
+
105
+ EffectiveRoles.assignable_roles_for(nil).should eq roles
106
+ EffectiveRoles.assignable_roles_for(superadmin).should eq roles
107
+ EffectiveRoles.assignable_roles_for(admin).should eq roles
108
+ EffectiveRoles.assignable_roles_for(member).should eq roles
109
+ EffectiveRoles.assignable_roles_for(user).should eq roles
110
+ end
111
+
112
+ end
113
+
114
+ describe '#disabled_roles' do
115
+ it 'uses the full Hash syntax to return the appropriate roles based on the passed User' do
116
+ EffectiveRoles.setup do |config|
117
+ config.disabled_roles = {
118
+ 'User' => [:member],
119
+ 'Post' => [:superadmin],
120
+ }
121
+ end
122
+
123
+ # On a User#edit screen
124
+ EffectiveRoles.disabled_roles_for(user).should eq [:member]
125
+ EffectiveRoles.disabled_roles_for(post).should eq [:superadmin]
126
+ EffectiveRoles.disabled_roles_for(nil).should eq []
127
+ end
128
+
129
+ it 'uses the lazy Hash syntax to return the appropriate roles based on the passed User' do
130
+ EffectiveRoles.setup do |config|
131
+ config.disabled_roles = {
132
+ 'User' => :member,
133
+ 'Post' => :superadmin,
134
+ }
135
+ end
136
+
137
+ # On a User#edit screen
138
+ EffectiveRoles.disabled_roles_for(user).should eq [:member]
139
+ EffectiveRoles.disabled_roles_for(post).should eq [:superadmin]
140
+ EffectiveRoles.disabled_roles_for(nil).should eq []
141
+ end
142
+
143
+ end
144
+
145
+
146
+
7
147
  end
@@ -3,13 +3,14 @@ ENV["RAILS_ENV"] ||= 'test'
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
 
5
5
  require 'rspec/rails'
6
- require 'rspec/autorun'
7
6
  require 'factory_girl_rails'
8
7
 
9
8
  # Requires supporting ruby files with custom matchers and macros, etc,
10
9
  # in spec/support/ and its subdirectories.
11
10
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f }
12
11
 
12
+ ActiveRecord::Migration.maintain_test_schema!
13
+
13
14
  RSpec.configure do |config|
14
15
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
15
16
 
@@ -18,6 +19,11 @@ RSpec.configure do |config|
18
19
  config.use_transactional_fixtures = true # Make this false to once again use DatabaseCleaner
19
20
  config.infer_base_class_for_anonymous_controllers = false
20
21
  config.order = 'random'
22
+
23
+ config.expect_with :rspec do |c|
24
+ c.syntax = [:should, :expect]
25
+ end
26
+
21
27
  end
22
28
 
23
29
  class ActiveRecord::Base
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,132 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_girl_rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: shoulda-matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-stack_explorer
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
27
153
  description: Assign multiple roles to any User or other ActiveRecord object. Select
28
154
  only the appropriate objects based on intelligent, chainable ActiveRecord::Relation
29
155
  finder methods.
@@ -52,6 +178,8 @@ files:
52
178
  - spec/dummy/app/assets/stylesheets/application.css
53
179
  - spec/dummy/app/controllers/application_controller.rb
54
180
  - spec/dummy/app/helpers/application_helper.rb
181
+ - spec/dummy/app/models/post.rb
182
+ - spec/dummy/app/models/user.rb
55
183
  - spec/dummy/app/views/layouts/application.html.erb
56
184
  - spec/dummy/config.ru
57
185
  - spec/dummy/config/application.rb
@@ -67,18 +195,10 @@ files:
67
195
  - spec/dummy/config/initializers/secret_token.rb
68
196
  - spec/dummy/config/initializers/session_store.rb
69
197
  - spec/dummy/config/initializers/wrap_parameters.rb
70
- - spec/dummy/config/locales/en.yml
71
198
  - spec/dummy/config/routes.rb
72
- - spec/dummy/db/development.sqlite3
73
199
  - spec/dummy/db/schema.rb
74
200
  - spec/dummy/db/test.sqlite3
75
- - spec/dummy/log/development.log
76
201
  - spec/dummy/log/test.log
77
- - spec/dummy/public/404.html
78
- - spec/dummy/public/422.html
79
- - spec/dummy/public/500.html
80
- - spec/dummy/public/favicon.ico
81
- - spec/dummy/script/rails
82
202
  - spec/effective_roles_spec.rb
83
203
  - spec/spec_helper.rb
84
204
  - spec/support/factories.rb
@@ -113,6 +233,8 @@ test_files:
113
233
  - spec/dummy/app/assets/stylesheets/application.css
114
234
  - spec/dummy/app/controllers/application_controller.rb
115
235
  - spec/dummy/app/helpers/application_helper.rb
236
+ - spec/dummy/app/models/post.rb
237
+ - spec/dummy/app/models/user.rb
116
238
  - spec/dummy/app/views/layouts/application.html.erb
117
239
  - spec/dummy/config/application.rb
118
240
  - spec/dummy/config/boot.rb
@@ -127,21 +249,13 @@ test_files:
127
249
  - spec/dummy/config/initializers/secret_token.rb
128
250
  - spec/dummy/config/initializers/session_store.rb
129
251
  - spec/dummy/config/initializers/wrap_parameters.rb
130
- - spec/dummy/config/locales/en.yml
131
252
  - spec/dummy/config/routes.rb
132
253
  - spec/dummy/config.ru
133
- - spec/dummy/db/development.sqlite3
134
254
  - spec/dummy/db/schema.rb
135
255
  - spec/dummy/db/test.sqlite3
136
- - spec/dummy/log/development.log
137
256
  - spec/dummy/log/test.log
138
- - spec/dummy/public/404.html
139
- - spec/dummy/public/422.html
140
- - spec/dummy/public/500.html
141
- - spec/dummy/public/favicon.ico
142
257
  - spec/dummy/Rakefile
143
258
  - spec/dummy/README.rdoc
144
- - spec/dummy/script/rails
145
259
  - spec/effective_roles_spec.rb
146
260
  - spec/spec_helper.rb
147
261
  - spec/support/factories.rb
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,17 +0,0 @@
1
- Connecting to database specified by database.yml
2
-  (0.4ms) select sqlite_version(*)
3
-  (3.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
4
-  (2.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (38.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
6
- Connecting to database specified by database.yml
7
-  (1.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
8
- Connecting to database specified by database.yml
9
-  (0.1ms) select sqlite_version(*)
10
-  (2.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
11
- Connecting to database specified by database.yml
12
-  (1.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
13
-  (0.1ms) select sqlite_version(*)
14
-  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
15
-  (2.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
16
-  (0.1ms) SELECT version FROM "schema_migrations"
17
-  (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'