fortress 0.2.1 → 0.2.2

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: 3228b2df9776560d0160ae736f3f4decbd2ef0ec
4
- data.tar.gz: 07a6e8228daa35591a4085a9894aca112a0ccc74
3
+ metadata.gz: 8807ceb07a787af9e28880231b85215cd11e10c4
4
+ data.tar.gz: 916d0af542ab25823cac2db1df20d7810502f8ca
5
5
  SHA512:
6
- metadata.gz: eec57ac7d0927ebbf9e52606ed0c9cadf6fd71f4ff9491851fd776503c97f2ab8489ec5269d293490807c8efe1686c1285cd23cb4f191b225337df4dc11066f6
7
- data.tar.gz: a79e1f069fe5507ac33128edfa9cde2d4bc5401c06a93f51acecb850e955c0669103d1e719214711a1e8354d64b009b6bc1b75fee63630b74702ce6947f013f9
6
+ metadata.gz: 11fb3fce13b31dd8f0db8236051b7386df0c9d9007812aba764a4d2d1a724ef747e726a81ef939d2164a1f39ad46c7b2ddd8fc5c8d2d30200e629998a5add6a3
7
+ data.tar.gz: 38b701f41f66e26b1a7869fb7f08cfc54a2ce277c5bf3c328df2b0e189adceae8811364cdc9eb3607536a6e54b63d3c2f4eeced5014d33175be46973e1a54339
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /bin/
10
11
  *.bundle
11
12
  *.so
12
13
  *.o
@@ -3,3 +3,7 @@ rvm:
3
3
  - 2.1.0
4
4
  - 2.1.5
5
5
  - 2.2.0
6
+ - ruby-head
7
+ addons:
8
+ code_climate:
9
+ repo_token: 5b2e9bef339ffbbd7250cafaa4d0a7706550152dbebbea092dbe71b386065504
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'codeclimate-test-reporter', group: :test, require: nil
4
+
3
5
  # Specify your gem's dependencies in fortress.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fortress
2
2
 
3
- [![Build Status](https://travis-ci.org/YourCursus/fortress.svg?branch=master)](https://travis-ci.org/YourCursus/fortress) [![Code Climate](https://codeclimate.com/github/YourCursus/fortress/badges/gpa.svg)](https://codeclimate.com/github/YourCursus/fortress) [![Gem Version](https://badge.fury.io/rb/fortress.svg)](http://badge.fury.io/rb/fortress)
3
+ [![Build Status](https://travis-ci.org/YourCursus/fortress.svg?branch=master)](https://travis-ci.org/YourCursus/fortress) [![Code Climate](https://codeclimate.com/github/YourCursus/fortress/badges/gpa.svg)](https://codeclimate.com/github/YourCursus/fortress) [![Gem Version](https://badge.fury.io/rb/fortress.svg)](http://badge.fury.io/rb/fortress) [![Test Coverage](https://codeclimate.com/github/YourCursus/fortress/badges/coverage.svg)](https://codeclimate.com/github/YourCursus/fortress)
4
4
 
5
5
  Implement the simple but powerful protection: close everything and open the
6
6
  access explecitely.
@@ -43,7 +43,9 @@ module Fortress
43
43
  #
44
44
  module ClassMethods
45
45
  def fortress_allow(actions, options = {})
46
- Mechanism.authorise!(name, actions)
46
+ (options.blank? || actions == :all) &&
47
+ Mechanism.authorise!(name, actions)
48
+
47
49
  Mechanism.parse_options(self, actions, options) if options.present?
48
50
  end
49
51
  end
@@ -4,5 +4,5 @@
4
4
  # @author zedtux
5
5
  #
6
6
  module Fortress
7
- VERSION = '0.2.1'
7
+ VERSION = '0.2.2'
8
8
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Authorisations appending (YourCursus/fortress#7)' do
4
+ describe GuitarsController, type: :controller do
5
+ let(:controller) { 'GuitarsController' }
6
+ before { Fortress::Mechanism.initialize_authorisations }
7
+ context 'when calling the first time `fortress_allow` method' do
8
+ before { GuitarsController.fortress_allow [:index, :show] }
9
+ it 'should create a new authorisation for the controller' do
10
+ expect(Fortress::Mechanism.authorisations).to have_key(controller)
11
+ expect(Fortress::Mechanism.authorisations[controller])
12
+ .to eql(only: [:index, :show])
13
+ end
14
+ context 'when calling a second time `fortress_allow` method' do
15
+ before { GuitarsController.fortress_allow :create, if: true }
16
+ it 'should append keys to the existing controller authorisation' do
17
+ expect(Fortress::Mechanism.authorisations).to have_key(controller)
18
+ expect(Fortress::Mechanism.authorisations[controller])
19
+ .to eql(only: [:index, :show],
20
+ if: { method: true, actions: [:create] })
21
+ end
22
+ end
23
+ end
24
+
25
+ context 'when calling the first time `fortress_allow` method' do
26
+ before { GuitarsController.fortress_allow :all, except: :destroy }
27
+ it 'should create a new authorisation for the controller' do
28
+ expect(Fortress::Mechanism.authorisations).to have_key(controller)
29
+ expect(Fortress::Mechanism.authorisations[controller])
30
+ .to eql(all: true, except: [:destroy])
31
+ end
32
+ context 'when calling a second time `fortress_allow` method' do
33
+ before { GuitarsController.fortress_allow :destroy, if: true }
34
+ it 'should append keys to the existing controller authorisation' do
35
+ expect(Fortress::Mechanism.authorisations).to have_key(controller)
36
+ expect(Fortress::Mechanism.authorisations[controller])
37
+ .to eql(all: true, except: [:destroy],
38
+ if: { method: true, actions: [:destroy] })
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'action_controller/railtie'
2
5
  require 'rspec/rails'
3
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Hain
@@ -114,20 +114,7 @@ description: 'The rigths management libraries available today are all based on t
114
114
  then up to you to open the allowed actions.'
115
115
  email:
116
116
  - zedtux@zedroot.org
117
- executables:
118
- - bundler
119
- - erubis
120
- - htmldiff
121
- - ldiff
122
- - nokogiri
123
- - rackup
124
- - rails
125
- - rake
126
- - rspec
127
- - rubocop
128
- - ruby-parse
129
- - ruby-rewrite
130
- - thor
117
+ executables: []
131
118
  extensions: []
132
119
  extra_rdoc_files: []
133
120
  files:
@@ -140,19 +127,6 @@ files:
140
127
  - LICENSE.txt
141
128
  - README.md
142
129
  - Rakefile
143
- - bin/bundler
144
- - bin/erubis
145
- - bin/htmldiff
146
- - bin/ldiff
147
- - bin/nokogiri
148
- - bin/rackup
149
- - bin/rails
150
- - bin/rake
151
- - bin/rspec
152
- - bin/rubocop
153
- - bin/ruby-parse
154
- - bin/ruby-rewrite
155
- - bin/thor
156
130
  - fortress.gemspec
157
131
  - lib/fortress.rb
158
132
  - lib/fortress/configuration.rb
@@ -163,6 +137,7 @@ files:
163
137
  - spec/fixtures/application.rb
164
138
  - spec/fixtures/controllers.rb
165
139
  - spec/fortress/access_deny_spec.rb
140
+ - spec/fortress/authorisations_appending_spec.rb
166
141
  - spec/fortress/configuration_spec.rb
167
142
  - spec/fortress/controller_interface_spec.rb
168
143
  - spec/fortress/controller_spec.rb
@@ -198,6 +173,7 @@ test_files:
198
173
  - spec/fixtures/application.rb
199
174
  - spec/fixtures/controllers.rb
200
175
  - spec/fortress/access_deny_spec.rb
176
+ - spec/fortress/authorisations_appending_spec.rb
201
177
  - spec/fortress/configuration_spec.rb
202
178
  - spec/fortress/controller_interface_spec.rb
203
179
  - spec/fortress/controller_spec.rb
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'bundler' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('bundler', 'bundler')
data/bin/erubis DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'erubis' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('erubis', 'erubis')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'htmldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'ldiff')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'nokogiri' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('nokogiri', 'nokogiri')
data/bin/rackup DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rackup' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rack', 'rackup')
data/bin/rails DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rails' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('railties', 'rails')
data/bin/rake DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rake' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rake', 'rake')
data/bin/rspec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rspec-core', 'rspec')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rubocop' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rubocop', 'rubocop')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ruby-parse' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('parser', 'ruby-parse')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ruby-rewrite' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('parser', 'ruby-rewrite')
data/bin/thor DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'thor' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('thor', 'thor')