fume-cancan 0.0.3 → 0.0.4

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: 0378203f952dd0a573778829ab51c45d2b5e8557
4
- data.tar.gz: abcd36c3537b0b931204032283c577a9487c5134
3
+ metadata.gz: a44cc9b04b6d1dce0cb5e99fa29d73b93dfc1a8f
4
+ data.tar.gz: 7d62ff91b18c8cf9da74e6c381fb56c5ebceb538
5
5
  SHA512:
6
- metadata.gz: 48511a34661d03d0abb67eaa2b7539d8100d9db3d6b1e9c3c76849dc014de1323e6aa4d23b01982891d6ef791f063e4b340802f7b7dae7f1df2c0355fe03478b
7
- data.tar.gz: f51ebaba8813316754fe205ab8f113cc085c4a94a2bf684d47e3c859b3c2353a5f2451fdea28c1b4ee8d9fddea93ade05cf64f9afaedf229e1445a8fa8b6bc5a
6
+ metadata.gz: a56a4a62973747c678f2207665a2ccf3c2ce3d0b2f280a80e08fdd8d90cf2f8f6b03e86935bd71f4f25a4dd9df213e8d5b01907113b548bccbe55a7d43b96ddb
7
+ data.tar.gz: 38e1776396e523a9124bc002a986d88aed19e09237ed4c88ac941307f1ebb3996560a8fc68d62005d07ae759fe03507ba3f6f6a039f72b9cf4171bedbd5dd5c2
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Fume::Cancan
2
2
 
3
3
  [![Build Status](https://travis-ci.org/sunteya/fume-cancan.svg?branch=master)](https://travis-ci.org/sunteya/fume-cancan)
4
- [![Coverage Status](https://coveralls.io/repos/sunteya/fume-cancan/badge.png)](https://coveralls.io/r/sunteya/fume-cancan)
4
+ [![Coverage Status](https://coveralls.io/repos/sunteya/fume-cancan/badge.png?branch=master)](https://coveralls.io/r/sunteya/fume-cancan?branch=master)
5
5
 
6
6
  helper methods for CanCan
7
7
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency "cancancan"
29
29
 
30
- spec.add_development_dependency "rspec-rails", "~> 2.14.1"
31
- spec.add_development_dependency "combustion", "~> 0.5.1"
32
- spec.add_development_dependency "rspec-do_action", "~> 0.0.3"
30
+ spec.add_development_dependency "rspec-rails", "3.1.0"
31
+ spec.add_development_dependency "combustion", "0.5.2"
32
+ spec.add_development_dependency "rspec-do_action", "0.0.4"
33
33
  end
@@ -4,31 +4,28 @@ module Fume
4
4
  module Cancan
5
5
  module ControllerExtensions
6
6
  extend ActiveSupport::Concern
7
-
7
+
8
8
  module ClassMethods
9
- def authorize_object(options = {})
10
- filter_options = options.slice(:only, :except) if options.is_a?(Hash)
9
+ def authorize_object(*args)
10
+ options = args.extract_options!
11
+ object = args.shift || options[:object]
12
+
13
+ filter_options = options.slice(:only, :except)
11
14
  before_filter(filter_options || {}) do |controller|
12
- controller.send :authorize_object!, options
15
+ controller.send :authorize_object!, object, options
13
16
  end
14
17
  end
15
18
  end
16
-
19
+
17
20
  protected
18
- def authorize_object!(options)
19
- action = params[:action].to_sym
20
- case options
21
- when Hash
22
- authorize! action, options[:object]
23
- else
24
- authorize! action, options
25
- end
21
+ def authorize_object!(object, options = {})
22
+ action = (options[:action] || params[:action]).to_sym
23
+ authorize! action, object
26
24
  end
27
-
28
25
  end
29
26
  end
30
27
  end
31
28
 
32
29
  if defined? ActionController::Base
33
30
  ActionController::Base.send :include, ::Fume::Cancan::ControllerExtensions
34
- end
31
+ end
@@ -1,5 +1,5 @@
1
1
  module Fume
2
2
  module Cancan
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
- describe Fume::Cancan::ControllerExtensions, type: :controller do
3
+ RSpec.describe Fume::Cancan::ControllerExtensions, type: :controller do
4
4
  describe "#authorize_object" do
5
5
  controller(ApplicationController) {}
6
6
  action { get :index }
@@ -23,6 +23,25 @@ describe Fume::Cancan::ControllerExtensions, type: :controller do
23
23
  end
24
24
  end
25
25
 
26
+ context "then authorize_object with options" do
27
+ before { ability.can :index, :admin }
28
+
29
+ context "with except option" do
30
+ controller { authorize_object :other, except: [ :index ] }
31
+ it { is_expected_response_ok }
32
+ end
33
+
34
+ context "with object options" do
35
+ controller { authorize_object object: :admin }
36
+ it { is_expected_response_ok }
37
+ end
38
+
39
+ context "with action options" do
40
+ controller { authorize_object :admin, action: :read }
41
+ it { is_expected_access_denied }
42
+ end
43
+ end
44
+
26
45
  define_method :ability, -> { controller.current_ability }
27
46
  define_method :is_expected_access_denied, -> { expect { do_action }.to raise_error CanCan::AccessDenied }
28
47
  define_method :is_expected_response_ok, -> { do_action; expect(response.body).to eq "OK" }
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ require "simplecov"
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+ # SimpleCov.start
7
+
8
+ require "pry-nav"
9
+ require 'combustion'
10
+ Combustion.initialize! :action_controller
11
+ require "rspec/rails"
12
+ require "rspec-do_action"
13
+
14
+
15
+ RSpec.configure do |config|
16
+ config.infer_base_class_for_anonymous_controllers = false
17
+ end
@@ -1,19 +1,84 @@
1
- require "simplecov"
2
- require 'coveralls'
3
- Coveralls.wear!
4
- # SimpleCov.start
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
5
31
 
6
- require 'combustion'
7
- Combustion.initialize! :action_controller
8
- require "rspec/rails"
9
- require "rspec-do_action"
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
10
40
 
11
- require "pry-nav"
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
12
43
 
13
- RSpec.configure do |config|
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
- config.run_all_when_everything_filtered = true
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
16
48
  config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # Many RSpec users commonly either run the entire suite or an individual
59
+ # file, and it's useful to allow more verbose output when running an
60
+ # individual spec file.
61
+ if config.files_to_run.one?
62
+ # Use the documentation formatter for detailed output,
63
+ # unless a formatter has already been configured
64
+ # (e.g. via a command-line flag).
65
+ config.default_formatter = 'doc'
66
+ end
67
+
68
+ # Print the 10 slowest examples and example groups at the
69
+ # end of the spec run, to help surface which specs are running
70
+ # particularly slow.
71
+ config.profile_examples = 10
72
+
73
+ # Run specs in random order to surface order dependencies. If you find an
74
+ # order dependency and want to debug it, you can fix the order by providing
75
+ # the seed, which is printed after each run.
76
+ # --seed 1234
77
+ config.order = :random
17
78
 
18
- config.order = 'random'
79
+ # Seed global randomization in this process using the `--seed` CLI option.
80
+ # Setting this allows you to use `--seed` to deterministically reproduce
81
+ # test failures related to randomization by passing the same `--seed` value
82
+ # as the one that triggered the failure.
83
+ Kernel.srand config.seed
19
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fume-cancan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sunteya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,44 +98,44 @@ dependencies:
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 2.14.1
103
+ version: 3.1.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 2.14.1
110
+ version: 3.1.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: combustion
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.5.1
117
+ version: 0.5.2
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.5.1
124
+ version: 0.5.2
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec-do_action
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 0.0.3
131
+ version: 0.0.4
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 0.0.3
138
+ version: 0.0.4
139
139
  description: fume helper methods for CanCan
140
140
  email:
141
141
  - sunteya@gmail.com
@@ -150,7 +150,6 @@ files:
150
150
  - LICENSE.txt
151
151
  - README.md
152
152
  - Rakefile
153
- - config.ru
154
153
  - fume-cancan.gemspec
155
154
  - lib/fume-cancan.rb
156
155
  - lib/fume/cancan/controller_extensions.rb
@@ -161,6 +160,7 @@ files:
161
160
  - spec/internal/config/database.yml
162
161
  - spec/internal/config/routes.rb
163
162
  - spec/internal/db/schema.rb
163
+ - spec/rails_helper.rb
164
164
  - spec/spec_helper.rb
165
165
  homepage: https://github.com/sunteya/fume-cancan
166
166
  licenses:
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.2.0
185
+ rubygems_version: 2.2.2
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: fume helper methods for CanCan
@@ -193,4 +193,5 @@ test_files:
193
193
  - spec/internal/config/database.yml
194
194
  - spec/internal/config/routes.rb
195
195
  - spec/internal/db/schema.rb
196
+ - spec/rails_helper.rb
196
197
  - spec/spec_helper.rb
data/config.ru DELETED
@@ -1,7 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.require :default, :development
5
-
6
- Combustion.initialize!
7
- run Combustion::Application