allowy 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/LICENSE +21 -0
- data/README.md +1 -6
- data/allowy.gemspec +2 -0
- data/lib/allowy/matchers.rb +2 -0
- data/lib/allowy/rspec.rb +4 -4
- data/lib/allowy/version.rb +1 -1
- data/spec/access_control_spec.rb +2 -1
- data/spec/context_spec.rb +7 -7
- data/spec/rspec_spec.rb +1 -0
- data/spec/spec_helper.rb +4 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57eaeb7cde5ce2812a99438b3f1db2341c2fdac
|
4
|
+
data.tar.gz: 7f9f72f90ca54a18c64cbda8ac15e957ed14040a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e79765e66f531df1471f472f8dcaa50d9e6350e09680ae006d2884ba70665dcac854e893298394d64e28cb8d9f9116f3ff785ad66a9c88d3ea012acada4b54c
|
7
|
+
data.tar.gz: 6cbb86ae3ed61d41bdc501a5fe828f31d2469ac15abbf0078ff15a68d9c0714c432c3203b19a38287170e75b9f6748c046bcf004987bd639ad18868c20ed2d92
|
data/.travis.yml
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Dmytrii Nagirniak
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -330,9 +330,4 @@ bundle install
|
|
330
330
|
bundle exec rspec spec/
|
331
331
|
```
|
332
332
|
|
333
|
-
|
334
|
-
Pull requests are very welcome, but please include the specs.
|
335
|
-
|
336
|
-
# License
|
337
|
-
|
338
|
-
[MIT] (http://www.opensource.org/licenses/mit-license.php)
|
333
|
+
Pull requests are very welcome, but please include the specs.
|
data/allowy.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/dnagir/allowy"
|
11
11
|
s.summary = %q{Authorization with simplicity and explicitness in mind}
|
12
12
|
s.description = %q{Allowy provides CanCan-like way of checking permission but doesn't enforce a tight DSL giving you more control}
|
13
|
+
s.licenses = ["MIT"]
|
13
14
|
|
14
15
|
s.rubyforge_project = "allowy"
|
15
16
|
|
@@ -23,6 +24,7 @@ Gem::Specification.new do |s|
|
|
23
24
|
s.add_runtime_dependency "activesupport", ">= 3.2"
|
24
25
|
|
25
26
|
s.add_development_dependency "rspec"
|
27
|
+
s.add_development_dependency "its"
|
26
28
|
s.add_development_dependency "pry"
|
27
29
|
s.add_development_dependency "guard"
|
28
30
|
s.add_development_dependency "guard-rspec"
|
data/lib/allowy/matchers.rb
CHANGED
data/lib/allowy/rspec.rb
CHANGED
@@ -12,19 +12,19 @@ module Allowy
|
|
12
12
|
|
13
13
|
|
14
14
|
def should_authorize_for(*args)
|
15
|
-
allowy.
|
15
|
+
expect(allowy).to receive(:authorize!).with(*args)
|
16
16
|
end
|
17
17
|
|
18
18
|
def should_not_authorize_for(*args)
|
19
|
-
allowy.
|
19
|
+
expect(allowy).not_to receive(:authorize!).with(*args)
|
20
20
|
end
|
21
21
|
|
22
22
|
module ClassMethods
|
23
23
|
def ignore_authorization!
|
24
24
|
before(:each) do
|
25
25
|
registry = double 'Registry'
|
26
|
-
registry.
|
27
|
-
@controller.
|
26
|
+
allow(registry).to receive_messages(:can? => true, :cannot? => false, :authorize! => nil, access_control_for!: registry)
|
27
|
+
allow(@controller).to receive(:current_allowy).and_return registry
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/allowy/version.rb
CHANGED
data/spec/access_control_spec.rb
CHANGED
@@ -9,7 +9,8 @@ module Allowy
|
|
9
9
|
describe "#context as an arbitrary object" do
|
10
10
|
subject { access.context }
|
11
11
|
its(:to_s) { should == '123' }
|
12
|
-
its(:zero?) { should
|
12
|
+
its(:zero?) { should == false }
|
13
|
+
|
13
14
|
it "should be able to access the context" do
|
14
15
|
access.should be_able_to :context_is_123
|
15
16
|
end
|
data/spec/context_spec.rb
CHANGED
@@ -11,25 +11,25 @@ module Allowy
|
|
11
11
|
let(:access) { double("Access") }
|
12
12
|
|
13
13
|
it "should create a registry" do
|
14
|
-
Registry.
|
14
|
+
expect(Registry).to receive(:new).with(subject)
|
15
15
|
subject.current_allowy
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be able to check using can?" do
|
19
|
-
subject.current_allowy.
|
20
|
-
access.
|
19
|
+
expect(subject.current_allowy).to receive(:access_control_for!).with(123).and_return access
|
20
|
+
expect(access).to receive(:can?).with(:edit, 123)
|
21
21
|
subject.can?(:edit, 123)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should be able to check using cannot?" do
|
25
|
-
subject.current_allowy.
|
26
|
-
access.
|
25
|
+
expect(subject.current_allowy).to receive(:access_control_for!).with(123).and_return access
|
26
|
+
expect(access).to receive(:cannot?).with(:edit, 123)
|
27
27
|
subject.cannot?(:edit, 123)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should call authorize!" do
|
31
|
-
access.
|
32
|
-
subject.current_allowy.
|
31
|
+
expect(access).to receive(:authorize!).with :edit, 123
|
32
|
+
allow(subject.current_allowy).to receive(:access_control_for!).and_return access
|
33
33
|
subject.authorize! :edit, 123
|
34
34
|
end
|
35
35
|
end
|
data/spec/rspec_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'pry'
|
2
|
+
require 'its'
|
2
3
|
require 'allowy'
|
3
4
|
require 'allowy/matchers'
|
4
5
|
|
5
6
|
RSpec.configure do |c|
|
6
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
7
7
|
c.run_all_when_everything_filtered = true
|
8
|
+
c.expect_with :rspec do |c|
|
9
|
+
c.syntax = [:should, :expect]
|
10
|
+
end
|
8
11
|
end
|
9
12
|
|
10
13
|
class SampleAccess
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allowy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytrii Nagirniak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: its
|
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'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,8 +118,10 @@ extra_rdoc_files: []
|
|
104
118
|
files:
|
105
119
|
- ".gitignore"
|
106
120
|
- ".rspec"
|
121
|
+
- ".travis.yml"
|
107
122
|
- Gemfile
|
108
123
|
- Guardfile
|
124
|
+
- LICENSE
|
109
125
|
- README.md
|
110
126
|
- Rakefile
|
111
127
|
- allowy.gemspec
|
@@ -123,7 +139,8 @@ files:
|
|
123
139
|
- spec/rspec_spec.rb
|
124
140
|
- spec/spec_helper.rb
|
125
141
|
homepage: https://github.com/dnagir/allowy
|
126
|
-
licenses:
|
142
|
+
licenses:
|
143
|
+
- MIT
|
127
144
|
metadata: {}
|
128
145
|
post_install_message:
|
129
146
|
rdoc_options: []
|