aegis 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '=2.3.8'
4
+ gem "aegis", :path => '.'
5
+ gem 'rspec', '=1.2.9'
6
+ gem 'rspec-rails', '=1.2.9'
7
+ gem 'ruby-debug'
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aegis (2.5.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (2.3.8)
10
+ actionpack (= 2.3.8)
11
+ actionpack (2.3.8)
12
+ activesupport (= 2.3.8)
13
+ rack (~> 1.1.0)
14
+ activerecord (2.3.8)
15
+ activesupport (= 2.3.8)
16
+ activeresource (2.3.8)
17
+ activesupport (= 2.3.8)
18
+ activesupport (2.3.8)
19
+ columnize (0.3.1)
20
+ linecache (0.43)
21
+ rack (1.1.0)
22
+ rails (2.3.8)
23
+ actionmailer (= 2.3.8)
24
+ actionpack (= 2.3.8)
25
+ activerecord (= 2.3.8)
26
+ activeresource (= 2.3.8)
27
+ activesupport (= 2.3.8)
28
+ rake (>= 0.8.3)
29
+ rake (0.8.7)
30
+ rspec (1.2.9)
31
+ rspec-rails (1.2.9)
32
+ rack (>= 1.0.0)
33
+ rspec (>= 1.2.9)
34
+ ruby-debug (0.10.3)
35
+ columnize (>= 0.1)
36
+ ruby-debug-base (~> 0.10.3.0)
37
+ ruby-debug-base (0.10.3)
38
+ linecache (>= 0.3)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ aegis!
45
+ rails (= 2.3.8)
46
+ rspec (= 1.2.9)
47
+ rspec-rails (= 1.2.9)
48
+ ruby-debug
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.5.1
data/aegis.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aegis}
8
- s.version = "2.5.0"
8
+ s.version = "2.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Henning Koch", "Tobias Kraze"]
12
- s.date = %q{2010-10-07}
12
+ s.date = %q{2010-11-02}
13
13
  s.description = %q{Aegis is an authorization solution for Ruby on Rails that supports roles and a RESTish, resource-style declaration of permission rules.}
14
14
  s.email = %q{henning.koch@makandra.de}
15
15
  s.extra_rdoc_files = [
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
+ "Gemfile",
21
+ "Gemfile.lock",
20
22
  "MIT-LICENSE",
21
23
  "README.rdoc",
22
24
  "Rakefile",
@@ -45,7 +47,6 @@ Gem::Specification.new do |s|
45
47
  "spec/aegis/spec/matchers_spec.rb",
46
48
  "spec/app_root/app/controllers/application_controller.rb",
47
49
  "spec/app_root/app/controllers/reviews_controller.rb",
48
- "spec/app_root/app/controllers/songs_controller.rb",
49
50
  "spec/app_root/app/models/permissions.rb",
50
51
  "spec/app_root/app/models/property.rb",
51
52
  "spec/app_root/app/models/review.rb",
@@ -82,7 +83,6 @@ Also see http://wiki.github.com/makandra/aegis/controller-integration
82
83
  s.test_files = [
83
84
  "spec/app_root/app/controllers/application_controller.rb",
84
85
  "spec/app_root/app/controllers/reviews_controller.rb",
85
- "spec/app_root/app/controllers/songs_controller.rb",
86
86
  "spec/app_root/app/models/permissions.rb",
87
87
  "spec/app_root/app/models/property.rb",
88
88
  "spec/app_root/app/models/review.rb",
@@ -47,7 +47,7 @@ module Aegis
47
47
  actions_map
48
48
  )
49
49
  args = []
50
- args << send(user_method)
50
+ args << permissions.call.send(:handle_missing_user, send(user_method))
51
51
  args << send(parent_object_method) if action.takes_parent_object
52
52
  args << send(object_method) if action.takes_object
53
53
  action.may!(*args)
@@ -12,9 +12,9 @@ module Aegis
12
12
  @missing_action_strategy = strategy
13
13
  end
14
14
 
15
- def missing_user_means(&strategy)
15
+ def missing_user_means(strategy_symbol = nil, &strategy_block)
16
16
  prepare
17
- @missing_user_strategy = strategy
17
+ @missing_user_strategy = strategy_symbol || strategy_block
18
18
  end
19
19
 
20
20
  def alias_action(aliases)
@@ -69,9 +69,9 @@ describe Aegis::Controller do
69
69
  end
70
70
  controller = @controller_class.new
71
71
  permissions_class.stub(:guess_action => stub('action', :takes_object => true, :takes_parent_object => true).as_null_object)
72
- controller.should_receive(:object)
73
- controller.should_receive(:parent_object)
74
- controller.should_receive(:current_user)
72
+ controller.should_receive(:object).and_return('the object')
73
+ controller.should_receive(:parent_object).and_return('the parent object')
74
+ controller.should_receive(:current_user).and_return('the user')
75
75
  controller.send(:check_permissions)
76
76
  end
77
77
 
@@ -82,9 +82,9 @@ describe Aegis::Controller do
82
82
  end
83
83
  controller = @controller_class.new
84
84
  permissions_class.stub(:guess_action => stub('action', :takes_object => true, :takes_parent_object => true).as_null_object)
85
- controller.should_receive(:my_object)
86
- controller.should_receive(:my_parent)
87
- controller.should_receive(:my_user)
85
+ controller.should_receive(:my_object).and_return('the object')
86
+ controller.should_receive(:my_parent).and_return('the parent object')
87
+ controller.should_receive(:my_user).and_return('the user')
88
88
  controller.send(:check_permissions)
89
89
  end
90
90
 
@@ -579,7 +579,14 @@ describe Aegis::Permissions do
579
579
 
580
580
  describe 'behavior when checking permissions without a user' do
581
581
 
582
- it "should raise an error if the user is nil" do
582
+ it "should raise an error if no missing user strategy is defined" do
583
+ expect { @permissions.may?(nil, :some_action) }.to raise_error(Aegis::MissingUser)
584
+ end
585
+
586
+ it 'should raise an error if the missing user strategy is :error' do
587
+ @permissions.class_eval do
588
+ missing_user_means :error
589
+ end
583
590
  expect { @permissions.may?(nil, :some_action) }.to raise_error(Aegis::MissingUser)
584
591
  end
585
592
 
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
4
4
  require_permissions
5
5
 
6
6
  def current_user
7
- User.new(:role_name => 'user')
7
+ nil # test missing_user_means
8
8
  end
9
9
 
10
10
  end
@@ -2,6 +2,8 @@ class Permissions < Aegis::Permissions
2
2
 
3
3
  role :user
4
4
 
5
+ missing_user_means { User.new(:role_name => 'user') }
6
+
5
7
  resources :properties do
6
8
  resources :reviews do
7
9
  reading do
@@ -10,9 +12,5 @@ class Permissions < Aegis::Permissions
10
12
  end
11
13
  end
12
14
 
13
- resources :maps do
14
- action :with_permission, :collection => true
15
- end
16
-
17
15
  end
18
16
 
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ ENV['RAILS_ENV'] ||= 'in_memory'
5
5
 
6
6
  # Load the Rails environment and testing framework
7
7
  require "#{File.dirname(__FILE__)}/app_root/config/environment"
8
- require "#{File.dirname(__FILE__)}/../lib/aegis"
8
+ # require "#{File.dirname(__FILE__)}/../lib/aegis"
9
9
  require 'spec/rails'
10
10
 
11
11
  # Undo changes to RAILS_ENV
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aegis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 0
10
- version: 2.5.0
9
+ - 1
10
+ version: 2.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-07 00:00:00 +02:00
19
+ date: 2010-11-02 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -30,6 +30,8 @@ extra_rdoc_files:
30
30
  - README.rdoc
31
31
  files:
32
32
  - .gitignore
33
+ - Gemfile
34
+ - Gemfile.lock
33
35
  - MIT-LICENSE
34
36
  - README.rdoc
35
37
  - Rakefile
@@ -58,7 +60,6 @@ files:
58
60
  - spec/aegis/spec/matchers_spec.rb
59
61
  - spec/app_root/app/controllers/application_controller.rb
60
62
  - spec/app_root/app/controllers/reviews_controller.rb
61
- - spec/app_root/app/controllers/songs_controller.rb
62
63
  - spec/app_root/app/models/permissions.rb
63
64
  - spec/app_root/app/models/property.rb
64
65
  - spec/app_root/app/models/review.rb
@@ -123,7 +124,6 @@ summary: Complete authorization solution for Rails
123
124
  test_files:
124
125
  - spec/app_root/app/controllers/application_controller.rb
125
126
  - spec/app_root/app/controllers/reviews_controller.rb
126
- - spec/app_root/app/controllers/songs_controller.rb
127
127
  - spec/app_root/app/models/permissions.rb
128
128
  - spec/app_root/app/models/property.rb
129
129
  - spec/app_root/app/models/review.rb
@@ -1,8 +0,0 @@
1
- class SongsController
2
-
3
- require_permissions
4
-
5
- skip_permissions :only => :index
6
- permissions :songs, :only => :new
7
-
8
- end