netzke-cancan 0.7.0 → 0.8.0
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.
- data/README.rdoc +6 -2
- data/lib/netzke/cancan.rb +6 -4
- data/lib/netzke/cancan/version.rb +1 -1
- data/spec/netzke/cancan_spec.rb +3 -3
- metadata +2 -1
data/README.rdoc
CHANGED
@@ -4,16 +4,20 @@ netzke-cancan simply adds all {cancan}[https://github.com/ryanb/cancan] controll
|
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
7
|
-
In Rails 3, add this to your gem file and run the +bundle+ command.
|
7
|
+
In Rails 3 and with the latest netzke version, add this to your gem file and run the +bundle+ command.
|
8
8
|
|
9
9
|
gem 'netzke-cancan'
|
10
10
|
|
11
|
+
If you are on Netzke 0.7.x, add this to your gemfile:
|
12
|
+
|
13
|
+
gem 'netzke-cancan', '~> 0.7.0'
|
14
|
+
|
11
15
|
== Usage
|
12
16
|
|
13
17
|
Simply use all cancan helper methods like can?, cannot? or authorize! in your Netzke components the same way you would do that inside of your controller.
|
14
18
|
|
15
19
|
== Contributing to netzke-cancan
|
16
|
-
|
20
|
+
|
17
21
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
18
22
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
19
23
|
* Fork the project.
|
data/lib/netzke/cancan.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Netzke
|
2
2
|
class Base
|
3
3
|
|
4
|
-
# This method
|
4
|
+
# This method returns the current ability with the current user from
|
5
|
+
# the controller.
|
5
6
|
#
|
6
7
|
# @return [Ability]
|
7
8
|
def current_ability
|
8
|
-
@current_ability ||= Ability.new(Netzke::
|
9
|
+
@current_ability ||= Ability.new(Netzke::Base.controller.current_user)
|
9
10
|
end
|
10
11
|
|
11
|
-
# cancan calls helper_method, which is present in any controller, but not
|
12
|
+
# cancan calls helper_method, which is present in any controller, but not
|
13
|
+
# in a netzke component
|
12
14
|
#
|
13
15
|
# @params *args
|
14
16
|
def self.helper_method(*args)
|
@@ -18,4 +20,4 @@ module Netzke
|
|
18
20
|
# Include the cancan controller additions
|
19
21
|
include ::CanCan::ControllerAdditions
|
20
22
|
end
|
21
|
-
end
|
23
|
+
end
|
data/spec/netzke/cancan_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Netzke::CanCan do
|
4
4
|
before(:each) do
|
5
5
|
user = Object.new
|
6
|
-
stub(Netzke::
|
6
|
+
stub(Netzke::Base).controller.stub!.current_user{user}
|
7
7
|
@component = TestComponent.new
|
8
8
|
end
|
9
9
|
|
@@ -14,7 +14,7 @@ describe Netzke::CanCan do
|
|
14
14
|
it "should respond to cannot?" do
|
15
15
|
@component.should respond_to(:cannot?)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
describe "#current_ability" do
|
19
19
|
it "should respond_to current_ability" do
|
20
20
|
@component.should respond_to(:current_ability)
|
@@ -24,4 +24,4 @@ describe Netzke::CanCan do
|
|
24
24
|
@component.current_ability.should be_a(Ability)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-cancan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -131,3 +131,4 @@ signing_key:
|
|
131
131
|
specification_version: 3
|
132
132
|
summary: Enables cancan in Netzke components
|
133
133
|
test_files: []
|
134
|
+
has_rdoc:
|