cantango-api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,8 +6,8 @@ group :default do
6
6
  gem 'sweetloader', '~> 0.1.6'
7
7
  gem 'hashie', '~> 1.2'
8
8
 
9
- gem 'cantango-config', '>= 0.1.8.1'
10
- gem 'cantango-core', '>= 0.1.9.1'
9
+ gem 'cantango-config', '>= 0.1.9.2'
10
+ gem 'cantango-core', '>= 0.1.9.2'
11
11
  end
12
12
 
13
13
  group :development do
@@ -19,7 +19,7 @@ end
19
19
  group :test do
20
20
  gem 'require_all', '~> 1.2.0'
21
21
 
22
- # gem 'cantango-masquerade', :git => 'git://github.com/kristianmandrup/cantango-masquerade.git'
22
+ gem 'cantango-masquerade', '>= 0.1.3.2'
23
23
 
24
24
  gem 'forgery'
25
25
  gem 'sqlite3'
data/Gemfile.lock CHANGED
@@ -44,6 +44,12 @@ GEM
44
44
  rails (>= 3.0.1)
45
45
  sugar-high (>= 0.6.0)
46
46
  sweetloader (~> 0.1.5)
47
+ cantango-masquerade (0.1.3.2)
48
+ cantango-core (>= 0.1.9.1)
49
+ hashie (~> 1.2)
50
+ rails (>= 3.1)
51
+ sugar-high (~> 0.6.2)
52
+ sweetloader (~> 0.1.6)
47
53
  colorize (0.5.8)
48
54
  cutter (0.8.2)
49
55
  activesupport (>= 2.3.5)
@@ -130,8 +136,9 @@ PLATFORMS
130
136
 
131
137
  DEPENDENCIES
132
138
  bundler (>= 1.1.rc)
133
- cantango-config (>= 0.1.8.1)
134
- cantango-core (>= 0.1.9.1)
139
+ cantango-config (>= 0.1.9.2)
140
+ cantango-core (>= 0.1.9.2)
141
+ cantango-masquerade (>= 0.1.3.2)
135
142
  cutter
136
143
  database_cleaner
137
144
  factory_girl
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/cantango-api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cantango-api}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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}]
12
- s.date = %q{2011-12-08}
12
+ s.date = %q{2011-12-09}
13
13
  s.description = %q{Ability, Can, Scope, Session, User, Account and more APIs for CanTango}
14
14
  s.email = %q{kristian@unity3d.com}
15
15
  s.extra_rdoc_files = [
@@ -102,8 +102,8 @@ Gem::Specification.new do |s|
102
102
  s.add_runtime_dependency(%q<sugar-high>, ["~> 0.6.2"])
103
103
  s.add_runtime_dependency(%q<sweetloader>, ["~> 0.1.6"])
104
104
  s.add_runtime_dependency(%q<hashie>, ["~> 1.2"])
105
- s.add_runtime_dependency(%q<cantango-config>, [">= 0.1.8.1"])
106
- s.add_runtime_dependency(%q<cantango-core>, [">= 0.1.9.1"])
105
+ s.add_runtime_dependency(%q<cantango-config>, [">= 0.1.9.2"])
106
+ s.add_runtime_dependency(%q<cantango-core>, [">= 0.1.9.2"])
107
107
  s.add_development_dependency(%q<bundler>, [">= 1.1.rc"])
108
108
  s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
109
109
  s.add_development_dependency(%q<rcov>, [">= 0"])
@@ -113,8 +113,8 @@ Gem::Specification.new do |s|
113
113
  s.add_dependency(%q<sugar-high>, ["~> 0.6.2"])
114
114
  s.add_dependency(%q<sweetloader>, ["~> 0.1.6"])
115
115
  s.add_dependency(%q<hashie>, ["~> 1.2"])
116
- s.add_dependency(%q<cantango-config>, [">= 0.1.8.1"])
117
- s.add_dependency(%q<cantango-core>, [">= 0.1.9.1"])
116
+ s.add_dependency(%q<cantango-config>, [">= 0.1.9.2"])
117
+ s.add_dependency(%q<cantango-core>, [">= 0.1.9.2"])
118
118
  s.add_dependency(%q<bundler>, [">= 1.1.rc"])
119
119
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
120
120
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -125,8 +125,8 @@ Gem::Specification.new do |s|
125
125
  s.add_dependency(%q<sugar-high>, ["~> 0.6.2"])
126
126
  s.add_dependency(%q<sweetloader>, ["~> 0.1.6"])
127
127
  s.add_dependency(%q<hashie>, ["~> 1.2"])
128
- s.add_dependency(%q<cantango-config>, [">= 0.1.8.1"])
129
- s.add_dependency(%q<cantango-core>, [">= 0.1.9.1"])
128
+ s.add_dependency(%q<cantango-config>, [">= 0.1.9.2"])
129
+ s.add_dependency(%q<cantango-core>, [">= 0.1.9.2"])
130
130
  s.add_dependency(%q<bundler>, [">= 1.1.rc"])
131
131
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
132
132
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -5,7 +5,7 @@ module CanTango::Api
5
5
 
6
6
  def scope_account scope, options = {}, &block
7
7
  account = scoped_account(scope)
8
- ab_scope = account_ability_scope(account, options.merge(:masquerade => true))
8
+ ab_scope = account_ability_scope(account, options)
9
9
  yield ab_scope if block
10
10
  ab_scope
11
11
  end
@@ -3,6 +3,5 @@ module CanTango::Macros
3
3
  def tango_account options = {}
4
4
  self.send :include, CanTango::Api::Model::Account
5
5
  end
6
- alias_method :cantango_account, :tango_account
7
6
  end
8
7
  end
@@ -4,7 +4,6 @@ require 'helpers/current_user_accounts'
4
4
 
5
5
  class Context
6
6
  include CanTango::Api::Scope::Account
7
- include CanTango::Api::Masquerade::Account
8
7
 
9
8
  include_and_extend ::CurrentUserAccounts
10
9
  end
@@ -14,29 +13,32 @@ class UserAccount
14
13
  end
15
14
 
16
15
  class AdminAccount
17
- cantango_account
16
+ tango_account :masquerade
18
17
  end
19
18
 
20
19
  describe CanTango::Api::Scope::Account do
21
20
  subject { Context.new }
22
21
 
23
22
  before do
24
- subject.masquerade_as subject.current_admin_account
23
+ subject.current_admin_account.masquerade_as(subject.current_user_account)
24
+ end
25
+
26
+ describe 'registered accounts' do
27
+ specify { CanTango.config.accounts.registered.should include(:user, :admin) }
25
28
  end
26
29
 
27
30
  describe 'scope_account(scope, options)' do
28
31
  specify do
29
- subject.scope_account :user do |user|
30
- user.candidate.class.should == subject.current_admin_account.class
32
+ subject.scope_account :user do |ability|
33
+ ability.subject.class.should == subject.current_user_account.class
31
34
  end
32
35
  end
33
36
  end
34
37
 
35
38
  describe 'real_account(scope, options)' do
36
39
  specify do
37
- subject.real_account :user do |user|
38
- user.candidate.class.should == subject.current_user_account.class
39
- user.candidate.user.should == subject.current_user_account.user
40
+ subject.real_account :admin do |ability|
41
+ ability.subject.class.should == subject.current_admin_account.class
40
42
  end
41
43
  end
42
44
  end
@@ -10,11 +10,11 @@ module CurrentUserAccounts
10
10
  end
11
11
 
12
12
  def current_user_account
13
- ::UserAccount.new(current_user, :roles => [:user])
13
+ @current_user_account ||= ::UserAccount.new(current_user, :roles => [:user])
14
14
  end
15
15
 
16
16
  def current_admin_account
17
- ::AdminAccount.new(current_admin, :roles => [:admin])
17
+ @current_admin_account ||= ::AdminAccount.new(current_admin, :roles => [:admin])
18
18
  end
19
19
  end
20
20
 
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'require_all'
4
4
  require 'cantango/core'
5
5
  require 'cantango/configuration'
6
6
  require 'cantango/api'
7
+ require 'cantango/masquerade'
7
8
 
8
9
  # require_all File.join("#{File.dirname(__FILE__)}", "support")
9
10
  require_all File.join("#{File.dirname(__FILE__)}", "fixtures")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantango-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-08 00:00:00.000000000Z
12
+ date: 2011-12-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70114366393220 !ruby/object:Gem::Requirement
16
+ requirement: &70206619585940 !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: *70114366393220
24
+ version_requirements: *70206619585940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sugar-high
27
- requirement: &70114366392120 !ruby/object:Gem::Requirement
27
+ requirement: &70206619584480 !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: *70114366392120
35
+ version_requirements: *70206619584480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sweetloader
38
- requirement: &70114366390820 !ruby/object:Gem::Requirement
38
+ requirement: &70206619583740 !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: *70114366390820
46
+ version_requirements: *70206619583740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hashie
49
- requirement: &70114366388960 !ruby/object:Gem::Requirement
49
+ requirement: &70206619583100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,32 +54,32 @@ dependencies:
54
54
  version: '1.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70114366388960
57
+ version_requirements: *70206619583100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cantango-config
60
- requirement: &70114366386640 !ruby/object:Gem::Requirement
60
+ requirement: &70206619582400 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 0.1.8.1
65
+ version: 0.1.9.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70114366386640
68
+ version_requirements: *70206619582400
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cantango-core
71
- requirement: &70114366385140 !ruby/object:Gem::Requirement
71
+ requirement: &70206619581180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.1.9.1
76
+ version: 0.1.9.2
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70114366385140
79
+ version_requirements: *70206619581180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: bundler
82
- requirement: &70114366384140 !ruby/object:Gem::Requirement
82
+ requirement: &70206619579920 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.1.rc
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70114366384140
90
+ version_requirements: *70206619579920
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: jeweler
93
- requirement: &70114366382760 !ruby/object:Gem::Requirement
93
+ requirement: &70206619577860 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.6.4
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70114366382760
101
+ version_requirements: *70206619577860
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rcov
104
- requirement: &70114366381860 !ruby/object:Gem::Requirement
104
+ requirement: &70206619575720 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70114366381860
112
+ version_requirements: *70206619575720
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &70114366380620 !ruby/object:Gem::Requirement
115
+ requirement: &70206619573580 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: 2.6.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70114366380620
123
+ version_requirements: *70206619573580
124
124
  description: Ability, Can, Scope, Session, User, Account and more APIs for CanTango
125
125
  email: kristian@unity3d.com
126
126
  executables: []
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  segments:
216
216
  - 0
217
- hash: -3829316605648255715
217
+ hash: -2854044970758451050
218
218
  required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  none: false
220
220
  requirements: