simon_says 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 685f3f8f7cedb32fba2e7b051480920658a8da7e
4
- data.tar.gz: a09f1909ec655d6653737c4bf1fd78a9e3c7d8d8
3
+ metadata.gz: def24394416cde084dfc11e6bf8c8490c16f64ad
4
+ data.tar.gz: b41bf2b8ba3dec59f38232e1fd95d837f6a9dd59
5
5
  SHA512:
6
- metadata.gz: f4f436bc143a52f7ca03a90335fb227b1aa9794f1ed462c9c53cb5b26263538f603b23d37ec4cf4a5d7a7a8a192931d7b635d518bf5d28390b624cfca591ce08
7
- data.tar.gz: 0f677b3f2830329eb4765e082321a787e5d2037bad8b72f79af7471bff238c8604b7fc1f0a0a0c631c15787f45fbcbfcffb76e28b18c88f4e8a98c920a1efc7b
6
+ metadata.gz: c92b127087300e5d13aa60808ff5477d3f7d8c525c6fd39ffd3c2627fe7d3b8d939cbbc786d9a1fc74607c01b480f62293a55428ff9cf26346a83c7a43db3b79
7
+ data.tar.gz: d93d82ad00d4e97caf4ba5e52c3ac7e073cfce70395590f775b8438bd6b48a097e8ab333cc3d9f63279f8f23e0ef849ef3506b9c91b9fe2cfbd73e4c4c553384
data/.travis.yml CHANGED
@@ -2,10 +2,6 @@ language: ruby
2
2
  cache: bundler
3
3
  install: bundle install --jobs=3 --retry=3
4
4
  rvm:
5
- - "2.2.2"
6
- before_script:
7
- - cd test/rails_app/
8
- - RAILS_ENV=test bundle exec rake db:migrate db:fixtures:load
9
- - cd ../..
5
+ - "2.3.1"
10
6
  script:
11
7
  - bundle exec rake test
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.2.3'
2
+ ruby '2.3.1'
3
3
 
4
4
  # Specify your gem's dependencies in auth_lib.gemspec
5
5
  gemspec
data/lib/simon_says.rb CHANGED
@@ -3,6 +3,3 @@ require 'active_support'
3
3
  require "simon_says/version"
4
4
  require "simon_says/roleable"
5
5
  require "simon_says/authorizer"
6
-
7
- module SimonSays
8
- end
@@ -3,6 +3,7 @@ module SimonSays
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  class Denied < StandardError
6
+ # @private
6
7
  def initialize(as, required, actual)
7
8
  # TODO i18n for err message (as should be singluarized with 1 flag)
8
9
  super "Access denied; #{required * ', '} role is required. Current access is #{actual * ', '}"
@@ -13,37 +14,41 @@ module SimonSays
13
14
  class_attribute :default_authorization_scope
14
15
  end
15
16
 
16
- # Once +Authorizer+ is included these methods become
17
- # available to your controllers.
18
17
  module ClassMethods
19
18
  # Authentication convenience method (to keep things declarative).
20
19
  # This method just setups a +before_action+
21
20
  #
22
- # * +scope+ is a symbol or string and should correspond to some sort
23
- # of authentication scope (ie: +authenticate_user!+)
24
- # * +opts+ filter options
25
- #
26
- # ====== Example
21
+ # @param [Symbol, String] scope corresponds to some sort of authentication
22
+ # scope (ie: +authenticate_user!+)
23
+ # @param [Hash] opts before_action options
27
24
  #
25
+ # @example Authentication user scope
28
26
  # authenticate :user, expect: :index
29
- #
30
27
  def authenticate(scope, opts = {})
31
- before_action :"authenticate_#{scope}!", filter_options(opts)
28
+ before_action :"authenticate_#{scope}!", action_options(opts)
32
29
  end
33
30
 
34
31
  # Find and authorize a resource.
35
32
  #
36
- # * +resource+ the name of resource to find
37
- # * +roles+ one or more role symbols
38
- # * the last argument may also be a filter options hash
39
- #
40
- # ====== Example
33
+ # @param [Symbol, String] resource name of resource to find
34
+ # @param [Array<Symbol, String>] roles one or more role symbols or strings
35
+ # @param [Hash] opts before_action and finder options
36
+ # @param opts [Symbol] :from corresponds to an instance variable or method that
37
+ # returns an ActiveRecord scope or model instance. If the object +respond_to?+
38
+ # to the pluralized resource name it is called and used as the finder scope. This
39
+ # makes it easy to handle finding resource through associations.
40
+ # @param opts [Symbol] :find_attribute attribute resource is found by; by
41
+ # default, +:id+ is used
42
+ # @param opts [Symbol] :param_key params key for resource query; by default,
43
+ # +:id+ is used
44
+ # @param opts [Symbol] :through through model to use when finding resource
45
+ # @param opts [Symbol] :namespace resource namespace
41
46
  #
42
- # find_and_authorize :document, :create, :update :publish, through: :memberships
47
+ # @see #find_resource for finder option examples
43
48
  def find_and_authorize(resource, *roles)
44
49
  opts = roles.extract_options!
45
50
 
46
- before_action(filter_options(opts)) do
51
+ before_action(action_options(opts)) do
47
52
  find_resource resource, opts
48
53
 
49
54
  authorize roles, opts unless roles.empty?
@@ -52,43 +57,77 @@ module SimonSays
52
57
 
53
58
  # Find a resource
54
59
  #
55
- # * +resource+ the name of the resource to find
56
- # * +opts+ filter options
60
+ # @param [Symbol, String] resource name of resource to find
61
+ # @param [Hash] opts before_action and finder options
62
+ # @param opts [Symbol] :from corresponds to an instance variable or method that
63
+ # returns an ActiveRecord scope or model instance. If the object +respond_to?+
64
+ # to the pluralized resource name it is called and used as the finder scope. This
65
+ # makes it easy to handle finding resource through associations.
66
+ # @param opts [Symbol] :find_attribute attribute resource is found by; by
67
+ # default, +:id+ is used
68
+ # @param opts [Symbol] :param_key params key for resource query; by default,
69
+ # +:id+ is used
70
+ # @param opts [Symbol] :through through model to use when finding resource
71
+ # @param opts [Symbol] :namespace resource namespace
72
+ #
73
+ # @example Find with a +:through+ option
74
+ # find_and_authorize :document, :create, :update :publish, through: :memberships
75
+ # @example Find and authorize with a +:from+ option
76
+ # # +@site.pages+ would be finder scope and is treated like an association
77
+ # find_and_authorize :page, from: :site
78
+ # @example Find resource with a +:find_attribute+ option
79
+ # # the where clause is now +where(token: params[:id])+
80
+ # find_resource :image, find_attribute: :token
81
+ # @example Find a resource using a namespace
82
+ # # Admin::Report is the class and query scope used
83
+ # find_resource :report, namespace: :admin
57
84
  def find_resource(resource, opts = {})
58
- before_action(filter_options(opts)) do
85
+ before_action action_options(opts) do
59
86
  find_resource resource, opts
60
87
  end
61
88
  end
62
89
 
63
90
  # Authorize against a given resource
64
91
  #
65
- # * +resource+ the name of the resource to authorize against. The
66
- # resource should include +Roleable+ and define some set of
67
- # roles. This method also expect the record to be available as
68
- # an instance variable (which is the case if +find_resource+ is
69
- # called before hand)
70
- # * +roles+ one or more role symbols
71
- # * the last argument may also be a filter options hash
92
+ # @param [Symbol, String] resource name of resource to find
93
+ # @param [Array<Symbol, String>] roles one or more role symbols or strings
94
+ # @param [Hash] opts before_action options
95
+ #
96
+ # @example Authorize resource
97
+ # authorize_resource :admin, :support
72
98
  def authorize_resource(resource, *roles)
73
- before_action(filter_options(roles.extract_options!)) do
74
- authorize(roles, { resource: resource })
99
+ opts = roles.extract_options!
100
+
101
+ before_action action_options(opts) do
102
+ authorize roles, { resource: resource }
75
103
  end
76
104
  end
77
105
 
78
- def filter_options(options) # :nodoc:
106
+ # Extract before_action options from Hash
107
+ #
108
+ # @private
109
+ # @param [Hash] options input options hash
110
+ # @param options [Symbol] :expect before_action expect option
111
+ # @param options [Symbol] :only before_action only option
112
+ # @param options [Symbol] :prepend before_action prepend option
113
+ def action_options(options)
79
114
  { except: options.delete(:except), only: options.delete(:only), prepend: options.delete(:prepend) }
80
115
  end
81
116
  end
82
117
 
83
- # @returns Primary resource found; need for +authorize+ calls
84
- def find_resource(resource, options = {}) # :nodoc:
118
+ # Internal find_resource instance method
119
+ #
120
+ # @private
121
+ # @param [Symbol, String] resource name of resource to find
122
+ # @param [Hash] options finder options
123
+ def find_resource(resource, options = {})
85
124
  resource = resource.to_s
86
125
 
87
126
  scope, query = resource_scope_and_query(resource, options)
88
127
  through = options[:through] ? options[:through].to_s : nil
89
128
 
90
129
  assoc = through || (options[:from] ? resource.pluralize : nil)
91
- scope = scope.send(assoc) if assoc
130
+ scope = scope.send(assoc) if assoc && scope.respond_to?(assoc)
92
131
 
93
132
  record = scope.where(query).first!
94
133
 
@@ -100,8 +139,12 @@ module SimonSays
100
139
  instance_variable_set "@#{resource}", record
101
140
  end
102
141
 
103
-
104
- def authorize(required = nil, options) # :nodoc:
142
+ # Internal authorize instance method
143
+ #
144
+ # @private
145
+ # @param [Symbol, String] one or more required roles
146
+ # @param [Hash] options authorizer options
147
+ def authorize(required = nil, options)
105
148
  if through = options[:through]
106
149
  name = through.to_s.singularize.to_sym
107
150
  else
@@ -109,9 +152,10 @@ module SimonSays
109
152
  end
110
153
 
111
154
  attr = Roleable.registry[name]
112
- required ||= options[attr.to_sym]
113
155
 
156
+ required ||= options[attr.to_sym]
114
157
  required = [required] unless Array === required
158
+
115
159
  record = instance_variable_get("@#{name}")
116
160
 
117
161
  if record.nil? # must be devise scope
@@ -130,7 +174,8 @@ module SimonSays
130
174
 
131
175
  private
132
176
 
133
- def resource_scope_and_query(resource, options) # :nodoc:
177
+ # @private
178
+ def resource_scope_and_query(resource, options)
134
179
  if options[:through]
135
180
  field = "#{resource}_id"
136
181
 
@@ -148,8 +193,8 @@ module SimonSays
148
193
  scope = klass.classify.constantize
149
194
  end
150
195
 
151
- field ||= :id
152
- query ||= { field => params[:id] }
196
+ field ||= options.fetch(:find_attribute, :id)
197
+ query ||= { field => params[options.fetch(:param_key, :id)] }
153
198
 
154
199
  return scope, query
155
200
  end
@@ -8,7 +8,6 @@ module SimonSays
8
8
  end
9
9
 
10
10
  module ClassMethods
11
- ##
12
11
  # Provides a declarative method to introduce role based
13
12
  # access controller through a give integer mask.
14
13
  #
@@ -17,8 +16,15 @@ module SimonSays
17
16
  # attribute. This will also alter the names of the dynamically
18
17
  # generated methods.
19
18
  #
20
- # ===== Example
19
+ # Several methods are dynamically genreated when calling +has_roles+.
20
+ # The methods generated include a setter, a getter and a predicate
21
+ # method
21
22
  #
23
+ # @param [Array<Symbol, String>] roles array of role symbols or strings
24
+ # @param [Hash] opts options hash
25
+ # @param opts [Symbol] :as alternative prefix name instead of "role"
26
+ #
27
+ # @example Detailed example:
22
28
  # class User < ActiveRecord::Base
23
29
  # include SimonSays::Roleable
24
30
  #
@@ -31,12 +37,6 @@ module SimonSays
31
37
  # has_roles :create, :update, :publish, as: :access
32
38
  # end
33
39
  #
34
- # ===== Dynamic Methods
35
- #
36
- # Several methods are dynamically genreated when calling +has_roles+.
37
- # The methods generated include a setter, a getter and a predicate
38
- # method. For examples:
39
- #
40
40
  # User.new.roles
41
41
  # => []
42
42
  #
@@ -52,8 +52,6 @@ module SimonSays
52
52
  # User.new(roles: :read).has_role? :read
53
53
  # => true
54
54
  #
55
- # Here's an example using the +:as+ prefix option:
56
- #
57
55
  # Editor.new(access: %w[create update publish]).access
58
56
  # => [:create, :update, :publish]
59
57
  #
@@ -1,3 +1,3 @@
1
1
  module SimonSays
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.5'
3
3
  end
@@ -26,7 +26,7 @@ class Admin::ReportsControllerTest < ActionController::TestCase
26
26
  @controller.current_admin = @support
27
27
 
28
28
  assert_difference 'Admin::Report.count' do
29
- post :create, params: { report: { title: 'Test' }, format: :json }
29
+ post :create, params: { report: { title: 'Test' } }, format: :json
30
30
  end
31
31
  end
32
32
 
@@ -34,14 +34,14 @@ class Admin::ReportsControllerTest < ActionController::TestCase
34
34
  @controller.current_admin = @marketing
35
35
 
36
36
  assert_raises SimonSays::Authorizer::Denied do
37
- post :create, params: { report: { title: 'Test' }, format: :json }
37
+ post :create, params: { report: { title: 'Test' } }, format: :json
38
38
  end
39
39
  end
40
40
 
41
41
  test "show with access" do
42
42
  @controller.current_admin = @support
43
43
 
44
- get :show, params: { id: admin_reports(:report_one), format: :json }
44
+ get :show, params: { id: admin_reports(:report_one) }, format: :json
45
45
 
46
46
  assert_response :success
47
47
  end
@@ -50,14 +50,14 @@ class Admin::ReportsControllerTest < ActionController::TestCase
50
50
  @controller.current_admin = @marketing
51
51
 
52
52
  assert_raises SimonSays::Authorizer::Denied do
53
- get :show, params: { id: admin_reports(:report_one), format: :json }
53
+ get :show, params: { id: admin_reports(:report_one) }, format: :json
54
54
  end
55
55
  end
56
56
 
57
57
  test "update with access" do
58
58
  @controller.current_admin = @support
59
59
 
60
- patch :show, params: { id: admin_reports(:report_one), report: { title: 'Test' }, format: :json }
60
+ patch :show, params: { id: admin_reports(:report_one), report: { title: 'Test' } }, format: :json
61
61
 
62
62
  assert_response :success
63
63
  end
@@ -66,7 +66,7 @@ class Admin::ReportsControllerTest < ActionController::TestCase
66
66
  @controller.current_admin = @marketing
67
67
 
68
68
  assert_raises SimonSays::Authorizer::Denied do
69
- patch :show, params: { id: admin_reports(:report_one), report: { title: 'Test' }, format: :json }
69
+ patch :show, params: { id: admin_reports(:report_one), report: { title: 'Test' } }, format: :json
70
70
  end
71
71
  end
72
72
 
@@ -74,7 +74,7 @@ class Admin::ReportsControllerTest < ActionController::TestCase
74
74
  @controller.current_admin = @support
75
75
 
76
76
  assert_difference 'Admin::Report.count', -1 do
77
- delete :destroy, params: { id: admin_reports(:report_one), format: :json }
77
+ delete :destroy, params: { id: admin_reports(:report_one) }, format: :json
78
78
  end
79
79
  end
80
80
 
@@ -82,7 +82,7 @@ class Admin::ReportsControllerTest < ActionController::TestCase
82
82
  @controller.current_admin = @marketing
83
83
 
84
84
  assert_raises SimonSays::Authorizer::Denied do
85
- delete :destroy, params: { id: admin_reports(:report_one), format: :json }
85
+ delete :destroy, params: { id: admin_reports(:report_one) }, format: :json
86
86
  end
87
87
  end
88
88
  end
@@ -1,5 +1,5 @@
1
1
  require 'test_helper'
2
- require 'pry'
2
+
3
3
  class DocumentsControllerTest < ActionController::TestCase
4
4
  setup do
5
5
  @alpha = documents(:alpha)
@@ -20,7 +20,7 @@ class DocumentsControllerTest < ActionController::TestCase
20
20
  test "show" do
21
21
  as_bob!
22
22
 
23
- get :show, params: { id: @alpha.id, format: "json" }
23
+ get :show, params: { id: @alpha.id }, format: :json
24
24
 
25
25
  assert_response :success
26
26
  end
@@ -29,14 +29,14 @@ class DocumentsControllerTest < ActionController::TestCase
29
29
  as_jim!
30
30
 
31
31
  assert_raises ActiveRecord::RecordNotFound do
32
- get :show, params: { id: @alpha.id, format: :json }
32
+ get :show, params: { id: @alpha.id }, format: :json
33
33
  end
34
34
  end
35
35
 
36
36
  test "update with access" do
37
37
  as_bob!
38
38
 
39
- patch :update, params: { id: @alpha.id, document: { title: 'Test' }, format: :json }
39
+ patch :update, params: { id: @alpha.id, document: { title: 'Test' } }, format: :json
40
40
 
41
41
  assert_response :success
42
42
  end
@@ -45,7 +45,7 @@ class DocumentsControllerTest < ActionController::TestCase
45
45
  as_bob!
46
46
 
47
47
  assert_raises SimonSays::Authorizer::Denied do
48
- patch :update, params: { id: @beta.id, document: { title: 'Test' }, format: :json }
48
+ patch :update, params: { id: @beta.id, document: { title: 'Test' } }, format: :json
49
49
  end
50
50
  end
51
51
 
@@ -53,7 +53,7 @@ class DocumentsControllerTest < ActionController::TestCase
53
53
  as_jim!
54
54
 
55
55
  assert_raises ActiveRecord::RecordNotFound do
56
- patch :update, params: { id: @alpha.id, document: { title: 'Test' }, format: :json }
56
+ patch :update, params: { id: @alpha.id, document: { title: 'Test' } }, format: :json
57
57
  end
58
58
  end
59
59
 
@@ -61,7 +61,7 @@ class DocumentsControllerTest < ActionController::TestCase
61
61
  as_bob!
62
62
 
63
63
  assert_difference 'Document.count', -1 do
64
- delete :destroy, params: { id: @alpha.id, format: :json }
64
+ delete :destroy, params: { id: @alpha.id }, format: :json
65
65
  end
66
66
  end
67
67
 
@@ -69,7 +69,7 @@ class DocumentsControllerTest < ActionController::TestCase
69
69
  as_bob!
70
70
 
71
71
  assert_raises SimonSays::Authorizer::Denied do
72
- delete :destroy, params: { id: @beta.id, format: :json }
72
+ delete :destroy, params: { id: @beta.id }, format: :json
73
73
  end
74
74
  end
75
75
 
@@ -77,7 +77,7 @@ class DocumentsControllerTest < ActionController::TestCase
77
77
  as_jim!
78
78
 
79
79
  assert_raises ActiveRecord::RecordNotFound do
80
- delete :destroy, params: { id: @beta.id, format: :json }
80
+ delete :destroy, params: { id: @beta.id }, format: :json
81
81
  end
82
82
  end
83
83
  end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class ImagesControllerTest < ActionController::TestCase
4
+ setup do
5
+ @image = images(:image_one)
6
+
7
+ @controller.current_admin = users(:bob)
8
+ end
9
+
10
+ test 'get show with correct id parameter' do
11
+ get :show, params: { id: @image.token }, format: :json
12
+
13
+ assert_response :success
14
+ end
15
+
16
+ test 'get show with incorrect id parameter' do
17
+ assert_raises ActiveRecord::RecordNotFound do
18
+ get :show, params: { id: @image.id }, format: :json
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ class ImagesController < ApplicationController
2
+ respond_to :json
3
+
4
+ authenticate :user
5
+
6
+ find_resource :image, find_attribute: :token, only: :show # any role
7
+
8
+ def show
9
+ respond_with @image
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- class Admin < ActiveRecord::Base
1
+ class Admin < ApplicationRecord
2
2
  include SimonSays::Roleable
3
3
 
4
4
  has_roles :support, :content, :marketing, as: :access
@@ -1,2 +1,2 @@
1
- class Admin::Report < ActiveRecord::Base
1
+ class Admin::Report < ApplicationRecord
2
2
  end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,4 +1,4 @@
1
- class Document < ActiveRecord::Base
1
+ class Document < ApplicationRecord
2
2
  has_many :memberships
3
3
  has_many :users, through: :memberships
4
4
  end
@@ -0,0 +1,7 @@
1
+ class Image < ApplicationRecord
2
+ has_secure_token
3
+
4
+ def to_param
5
+ token
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
- class Membership < ActiveRecord::Base
1
+ class Membership < ApplicationRecord
2
2
  include SimonSays::Roleable
3
3
 
4
4
  belongs_to :user
@@ -1,4 +1,4 @@
1
- class User < ActiveRecord::Base
1
+ class User < ApplicationRecord
2
2
  has_many :memberships
3
3
  has_many :documents, through: :memberships
4
4
  end
@@ -4,4 +4,5 @@ Rails.application.routes.draw do
4
4
  end
5
5
 
6
6
  resources :documents
7
+ resources :images, only: :show
7
8
  end
@@ -1,4 +1,4 @@
1
- class CreateAdmins < ActiveRecord::Migration
1
+ class CreateAdmins < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :admins do |t|
4
4
  t.integer :access_mask
@@ -1,7 +1,6 @@
1
- class CreateUsers < ActiveRecord::Migration
1
+ class CreateUsers < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :users do |t|
4
-
5
4
  t.timestamps
6
5
  end
7
6
  end
@@ -1,4 +1,4 @@
1
- class CreateMemberships < ActiveRecord::Migration
1
+ class CreateMemberships < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :memberships do |t|
4
4
  t.references :user
@@ -1,4 +1,4 @@
1
- class CreateDocuments < ActiveRecord::Migration
1
+ class CreateDocuments < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :documents do |t|
4
4
  t.string :title
@@ -1,4 +1,4 @@
1
- class CreateAdminReports < ActiveRecord::Migration
1
+ class CreateAdminReports < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :admin_reports do |t|
4
4
  t.string :title
@@ -0,0 +1,9 @@
1
+ class CreateImages < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :token
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -11,37 +10,45 @@
11
10
  #
12
11
  # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(version: 20141017140833) do
13
+ ActiveRecord::Schema.define(version: 20160823220959) do
15
14
 
16
15
  create_table "admin_reports", force: :cascade do |t|
17
- t.string "title", limit: 255
18
- t.datetime "created_at"
19
- t.datetime "updated_at"
16
+ t.string "title"
17
+ t.datetime "created_at", null: false
18
+ t.datetime "updated_at", null: false
20
19
  end
21
20
 
22
21
  create_table "admins", force: :cascade do |t|
23
22
  t.integer "access_mask"
24
- t.datetime "created_at"
25
- t.datetime "updated_at"
23
+ t.datetime "created_at", null: false
24
+ t.datetime "updated_at", null: false
26
25
  end
27
26
 
28
27
  create_table "documents", force: :cascade do |t|
29
- t.string "title", limit: 255
30
- t.datetime "created_at"
31
- t.datetime "updated_at"
28
+ t.string "title"
29
+ t.datetime "created_at", null: false
30
+ t.datetime "updated_at", null: false
31
+ end
32
+
33
+ create_table "images", force: :cascade do |t|
34
+ t.string "token"
35
+ t.datetime "created_at", null: false
36
+ t.datetime "updated_at", null: false
32
37
  end
33
38
 
34
39
  create_table "memberships", force: :cascade do |t|
35
40
  t.integer "user_id"
36
41
  t.integer "document_id"
37
42
  t.integer "roles_mask", default: 0
38
- t.datetime "created_at"
39
- t.datetime "updated_at"
43
+ t.datetime "created_at", null: false
44
+ t.datetime "updated_at", null: false
45
+ t.index ["document_id"], name: "index_memberships_on_document_id"
46
+ t.index ["user_id"], name: "index_memberships_on_user_id"
40
47
  end
41
48
 
42
49
  create_table "users", force: :cascade do |t|
43
- t.datetime "created_at"
44
- t.datetime "updated_at"
50
+ t.datetime "created_at", null: false
51
+ t.datetime "updated_at", null: false
45
52
  end
46
53
 
47
54
  end
@@ -0,0 +1,2 @@
1
+ image_one:
2
+ token: abcdef
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ImageTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
data/test/test_helper.rb CHANGED
@@ -25,9 +25,6 @@ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_p
25
25
  ActiveRecord::Base.logger = Logger.new(nil)
26
26
  ActiveRecord::Migration.verbose = false
27
27
 
28
- ActiveRecord::Base.establish_connection(Rails.application.config.database_configuration[ENV['RAILS_ENV']])
29
- ActiveRecord::Migrator.migrate(File.expand_path("../rails_app/db/migrate/", __FILE__))
30
-
31
28
  class ActiveSupport::TestCase
32
29
  include ActiveRecord::TestFixtures
33
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simon_says
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Coyne
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-21 00:00:00.000000000 Z
13
+ date: 2016-09-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -133,6 +133,7 @@ files:
133
133
  - simon_says.gemspec
134
134
  - test/controllers/admin/reports_controller_test.rb
135
135
  - test/controllers/documents_controller_test.rb
136
+ - test/controllers/images_controller_test.rb
136
137
  - test/rails_app/.gitignore
137
138
  - test/rails_app/README.rdoc
138
139
  - test/rails_app/Rakefile
@@ -143,13 +144,16 @@ files:
143
144
  - test/rails_app/app/controllers/application_controller.rb
144
145
  - test/rails_app/app/controllers/concerns/.keep
145
146
  - test/rails_app/app/controllers/documents_controller.rb
147
+ - test/rails_app/app/controllers/images_controller.rb
146
148
  - test/rails_app/app/helpers/application_helper.rb
147
149
  - test/rails_app/app/mailers/.keep
148
150
  - test/rails_app/app/models/.keep
149
151
  - test/rails_app/app/models/admin.rb
150
152
  - test/rails_app/app/models/admin/report.rb
153
+ - test/rails_app/app/models/application_record.rb
151
154
  - test/rails_app/app/models/concerns/.keep
152
155
  - test/rails_app/app/models/document.rb
156
+ - test/rails_app/app/models/image.rb
153
157
  - test/rails_app/app/models/membership.rb
154
158
  - test/rails_app/app/models/user.rb
155
159
  - test/rails_app/app/views/layouts/application.html.erb
@@ -181,6 +185,7 @@ files:
181
185
  - test/rails_app/db/migrate/20141016183633_create_memberships.rb
182
186
  - test/rails_app/db/migrate/20141016183642_create_documents.rb
183
187
  - test/rails_app/db/migrate/20141017140833_create_admin_reports.rb
188
+ - test/rails_app/db/migrate/20160823220959_create_images.rb
184
189
  - test/rails_app/db/schema.rb
185
190
  - test/rails_app/db/seeds.rb
186
191
  - test/rails_app/lib/assets/.keep
@@ -196,6 +201,7 @@ files:
196
201
  - test/rails_app/test/fixtures/admin/reports.yml
197
202
  - test/rails_app/test/fixtures/admins.yml
198
203
  - test/rails_app/test/fixtures/documents.yml
204
+ - test/rails_app/test/fixtures/images.yml
199
205
  - test/rails_app/test/fixtures/memberships.yml
200
206
  - test/rails_app/test/fixtures/users.yml
201
207
  - test/rails_app/test/helpers/.keep
@@ -204,6 +210,7 @@ files:
204
210
  - test/rails_app/test/models/.keep
205
211
  - test/rails_app/test/models/admin/report_test.rb
206
212
  - test/rails_app/test/models/document_test.rb
213
+ - test/rails_app/test/models/image_test.rb
207
214
  - test/rails_app/test/models/membership_test.rb
208
215
  - test/rails_app/test/models/user_test.rb
209
216
  - test/rails_app/test/test_helper.rb
@@ -233,13 +240,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
240
  version: '0'
234
241
  requirements: []
235
242
  rubyforge_project:
236
- rubygems_version: 2.4.5.1
243
+ rubygems_version: 2.5.1
237
244
  signing_key:
238
245
  specification_version: 4
239
246
  summary: Light-weight, declarative authorization and access control for Rails
240
247
  test_files:
241
248
  - test/controllers/admin/reports_controller_test.rb
242
249
  - test/controllers/documents_controller_test.rb
250
+ - test/controllers/images_controller_test.rb
243
251
  - test/rails_app/.gitignore
244
252
  - test/rails_app/README.rdoc
245
253
  - test/rails_app/Rakefile
@@ -250,13 +258,16 @@ test_files:
250
258
  - test/rails_app/app/controllers/application_controller.rb
251
259
  - test/rails_app/app/controllers/concerns/.keep
252
260
  - test/rails_app/app/controllers/documents_controller.rb
261
+ - test/rails_app/app/controllers/images_controller.rb
253
262
  - test/rails_app/app/helpers/application_helper.rb
254
263
  - test/rails_app/app/mailers/.keep
255
264
  - test/rails_app/app/models/.keep
256
265
  - test/rails_app/app/models/admin.rb
257
266
  - test/rails_app/app/models/admin/report.rb
267
+ - test/rails_app/app/models/application_record.rb
258
268
  - test/rails_app/app/models/concerns/.keep
259
269
  - test/rails_app/app/models/document.rb
270
+ - test/rails_app/app/models/image.rb
260
271
  - test/rails_app/app/models/membership.rb
261
272
  - test/rails_app/app/models/user.rb
262
273
  - test/rails_app/app/views/layouts/application.html.erb
@@ -288,6 +299,7 @@ test_files:
288
299
  - test/rails_app/db/migrate/20141016183633_create_memberships.rb
289
300
  - test/rails_app/db/migrate/20141016183642_create_documents.rb
290
301
  - test/rails_app/db/migrate/20141017140833_create_admin_reports.rb
302
+ - test/rails_app/db/migrate/20160823220959_create_images.rb
291
303
  - test/rails_app/db/schema.rb
292
304
  - test/rails_app/db/seeds.rb
293
305
  - test/rails_app/lib/assets/.keep
@@ -303,6 +315,7 @@ test_files:
303
315
  - test/rails_app/test/fixtures/admin/reports.yml
304
316
  - test/rails_app/test/fixtures/admins.yml
305
317
  - test/rails_app/test/fixtures/documents.yml
318
+ - test/rails_app/test/fixtures/images.yml
306
319
  - test/rails_app/test/fixtures/memberships.yml
307
320
  - test/rails_app/test/fixtures/users.yml
308
321
  - test/rails_app/test/helpers/.keep
@@ -311,6 +324,7 @@ test_files:
311
324
  - test/rails_app/test/models/.keep
312
325
  - test/rails_app/test/models/admin/report_test.rb
313
326
  - test/rails_app/test/models/document_test.rb
327
+ - test/rails_app/test/models/image_test.rb
314
328
  - test/rails_app/test/models/membership_test.rb
315
329
  - test/rails_app/test/models/user_test.rb
316
330
  - test/rails_app/test/test_helper.rb