cantango-masquerade 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cantango-masquerade}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kristian Mandrup}]
@@ -37,6 +37,8 @@ Gem::Specification.new do |s|
37
37
  "lib/cantango/masquerade/macros/masquerader.rb",
38
38
  "lib/cantango/masquerade/macros/masquerader/account.rb",
39
39
  "lib/cantango/masquerade/macros/masquerader/user.rb",
40
+ "lib/cantango/masquerade/scope.rb",
41
+ "lib/cantango/masquerade/scope/ability.rb",
40
42
  "lib/cantango/masquerade_ext.rb",
41
43
  "lib/cantango/masquerade_ext/macros.rb",
42
44
  "lib/cantango/masquerade_ext/macros/account.rb",
@@ -49,6 +51,7 @@ Gem::Specification.new do |s|
49
51
  "spec/cantango/masquerade_ext/macros/admin_account_spec.rb",
50
52
  "spec/cantango/masquerade_ext/macros/admin_user_spec.rb",
51
53
  "spec/cantango/masquerade_spec.rb",
54
+ "spec/cantango/scope/ability_spec.rb",
52
55
  "spec/fixtures/models.rb",
53
56
  "spec/fixtures/models/admin.rb",
54
57
  "spec/fixtures/models/admin_account.rb",
@@ -7,7 +7,7 @@ SweetLoader.mode = :require
7
7
 
8
8
  module CanTango
9
9
  sweet_scope :ns => {:CanTango => 'cantango/masquerade'} do
10
- sweetload :Ability, :Api, :Macros
10
+ sweetload :Ability, :Api, :Macros, :Scope
11
11
  end
12
12
  end
13
13
 
@@ -1 +1 @@
1
- require 'cantango/masquerade/ability/helper/masquerade'
1
+ require 'cantango/masquerade/ability/helper/masquerade'
@@ -0,0 +1,7 @@
1
+ module CanTango
2
+ module Scope
3
+ sweet_scope :ns => {:CanTango => 'cantango/masquerade'} do
4
+ sweetload :Ability
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module CanTango
2
+ module Scope
3
+ class Ability
4
+ include CanTango::Ability::Helper::Masquerade
5
+ end
6
+ end
7
+ end
@@ -1,13 +1,13 @@
1
1
  module CanTango::Macros
2
2
  module Account
3
3
  def tango_account options = {}
4
- self.send :include, CanTango::Api::Account
4
+ self.send :include, CanTango::Api::Model::Account
5
5
  options = CanTango::Macros.extract(options) if options.kind_of? Array
6
6
 
7
7
  if defined? CanTango::Macros::Masquerader::Account
8
8
  self.send :include, CanTango::Macros::Masquerader::Account
9
9
  masquerader if options[:masquerade]
10
10
  end
11
- end
11
+ end
12
12
  end
13
13
  end
@@ -1,7 +1,7 @@
1
1
  module CanTango::Macros
2
2
  module User
3
3
  def tango_user options = {}
4
- self.send :include, CanTango::Api::User
4
+ self.send :include, CanTango::Api::Model::User
5
5
  options = CanTango::Macros.extract(options) if options.kind_of? Array
6
6
 
7
7
  if defined? CanTango::Macros::Masquerader::User
@@ -0,0 +1,81 @@
1
+ require 'cantango/config'
2
+ require 'fixtures/models'
3
+ require 'spec_helper'
4
+
5
+ class EditorUser
6
+ include CanTango::Api::Masquerade::User
7
+ end
8
+
9
+ class AdminUser
10
+ include CanTango::Api::Masquerade::User
11
+ end
12
+
13
+ CanTango.config.users do |u|
14
+ u.register :editor, EditorUser
15
+ u.register :admin, AdminUser
16
+ end
17
+
18
+ describe CanTango::Scope::Ability do
19
+ before do
20
+ @editor = EditorUser.new
21
+ @admin = AdminUser.new 'admin'
22
+ @ability = CanTango::Ability::Base.new @admin
23
+ end
24
+
25
+ # subject { CanTango::Scope::Ability.new @ability, :masquerade => false }
26
+ subject { CanTango::Scope::Ability.new @ability }
27
+
28
+ context 'NOT masquerading' do
29
+ before do
30
+ @admin.stop_masquerade
31
+ end
32
+
33
+ describe 'masquerading?' do
34
+ specify { subject.masquerading?.should be_false }
35
+ end
36
+
37
+ describe 'masquerade_user?' do
38
+ specify { subject.masquerade_user?.should be_false }
39
+ end
40
+
41
+ describe 'masquerade_account?' do
42
+ specify { subject.masquerade_account?.should be_false }
43
+ end
44
+
45
+ # describe 'masquerading_off?' do
46
+ # specify { subject.masquerade_off?.should be_true }
47
+ # end
48
+
49
+ describe 'subject' do
50
+ specify { subject.send(:subject).should == @admin }
51
+ end
52
+ end
53
+
54
+ context 'IS masquerading' do
55
+ before do
56
+ @admin.masquerade_as @editor
57
+ end
58
+
59
+ specify { @admin.active_user.should == @editor }
60
+
61
+ describe 'masquerading?' do
62
+ specify { subject.masquerading?.should be_true }
63
+ end
64
+
65
+ # describe 'masquerading_off?' do
66
+ # specify { subject.masquerade_off?.should be_true }
67
+ # end
68
+
69
+ describe 'masquerade_user?' do
70
+ specify { subject.masquerade_user?.should be_true }
71
+ end
72
+
73
+ describe 'masquerade_account?' do
74
+ specify { subject.masquerade_account?.should be_false }
75
+ end
76
+
77
+ describe 'subject' do
78
+ specify { subject.send(:subject).should == @editor }
79
+ end
80
+ end
81
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantango-masquerade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70205428633780 !ruby/object:Gem::Requirement
16
+ requirement: &70314881220300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70205428633780
24
+ version_requirements: *70314881220300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sugar-high
27
- requirement: &70205428632360 !ruby/object:Gem::Requirement
27
+ requirement: &70314881219060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70205428632360
35
+ version_requirements: *70314881219060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sweetloader
38
- requirement: &70205428630840 !ruby/object:Gem::Requirement
38
+ requirement: &70314881218300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.1.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70205428630840
46
+ version_requirements: *70314881218300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hashie
49
- requirement: &70205428628440 !ruby/object:Gem::Requirement
49
+ requirement: &70314881216320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70205428628440
57
+ version_requirements: *70314881216320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cantango-core
60
- requirement: &70205428627420 !ruby/object:Gem::Requirement
60
+ requirement: &70314881131800 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.1.9.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70205428627420
68
+ version_requirements: *70314881131800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70205428626420 !ruby/object:Gem::Requirement
71
+ requirement: &70314881129180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.1.rc
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70205428626420
79
+ version_requirements: *70314881129180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70205428625380 !ruby/object:Gem::Requirement
82
+ requirement: &70314881124480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.6.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70205428625380
90
+ version_requirements: *70314881124480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70205428623420 !ruby/object:Gem::Requirement
93
+ requirement: &70314881119540 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70205428623420
101
+ version_requirements: *70314881119540
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &70205428622440 !ruby/object:Gem::Requirement
104
+ requirement: &70314881116660 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 2.6.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70205428622440
112
+ version_requirements: *70314881116660
113
113
  description: Masquerade extensions and macros for CanTango
114
114
  email: kmandrup@gmail.com
115
115
  executables: []
@@ -138,6 +138,8 @@ files:
138
138
  - lib/cantango/masquerade/macros/masquerader.rb
139
139
  - lib/cantango/masquerade/macros/masquerader/account.rb
140
140
  - lib/cantango/masquerade/macros/masquerader/user.rb
141
+ - lib/cantango/masquerade/scope.rb
142
+ - lib/cantango/masquerade/scope/ability.rb
141
143
  - lib/cantango/masquerade_ext.rb
142
144
  - lib/cantango/masquerade_ext/macros.rb
143
145
  - lib/cantango/masquerade_ext/macros/account.rb
@@ -150,6 +152,7 @@ files:
150
152
  - spec/cantango/masquerade_ext/macros/admin_account_spec.rb
151
153
  - spec/cantango/masquerade_ext/macros/admin_user_spec.rb
152
154
  - spec/cantango/masquerade_spec.rb
155
+ - spec/cantango/scope/ability_spec.rb
153
156
  - spec/fixtures/models.rb
154
157
  - spec/fixtures/models/admin.rb
155
158
  - spec/fixtures/models/admin_account.rb
@@ -177,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
180
  version: '0'
178
181
  segments:
179
182
  - 0
180
- hash: 725092924563287622
183
+ hash: 1941294774198972126
181
184
  required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  none: false
183
186
  requirements: