spec/cantango/api/scope/user_spec.rb in cantango-api-0.0.0 vs spec/cantango/api/scope/user_spec.rb in cantango-api-0.1.0
- old
+ new
@@ -1,73 +1,41 @@
-require 'rspec'
-require 'cantango'
-require 'simple_roles'
+require 'spec_helper'
require 'fixtures/models'
-require 'cantango/api/current_users'
-# require 'cantango/configuration/engines/store_engine_shared'
+require 'helpers/current_users'
-CanTango.configure do |config|
- config.users.register :user, User
- config.users.register :admin, Admin
+class Context
+ include CanTango::Api::Scope::User
- config.cache_engine.set :off
- config.permit_engine.set :on
+ include_and_extend ::CurrentUsers
end
-# puts "#{CanTango.config.users.registered_classes} : #{CanTango.config.users.registered}"
-
class User
- include CanTango::Users::Masquerade
- include_and_extend ::SimpleRoles
+ cantango
end
-class Context
- include CanTango::Api::User::Ability
- include CanTango::Api::User::Scope
-
- include_and_extend ::CurrentUsers
+class AdminUser
+ cantango
end
-describe CanTango::Api::User::Scope do
+describe CanTango::Api::Scope::User do
subject { Context.new }
- describe 'scope_user' do
- before do
- subject.current_admin.masquerade_as subject.current_user
- end
+ before do
+ subject.current_user.active_account = subject.current_admin
+ end
+ describe 'scope_user(scope, options)' do
specify do
- subject.scope_user(:admin) do |user|
- user.should be_a CanTango::Ability::Scope
- user.ability.user.name.should == 'admin'
+ subject.scope_user :user do |user|
+ user.candidate.should == subject.current_admin
end
end
-
- specify do
- admin = subject.scope_user(:user)
- admin.should be_a CanTango::Ability::Scope
- admin.ability.user.name.should == 'stan'
- end
end
- describe 'real_user' do
- before do
- subject.current_user.masquerade_as subject.current_admin
- end
-
+ describe 'real_user(scope, options)' do
specify do
- subject.real_user(:user) do |user|
- user.should be_a CanTango::Ability::Scope
- user.ability.user.name.should == 'stan'
+ subject.real_user :user do |user|
+ user.candidate.should == subject.current_user
end
end
-
- specify do
- admin = subject.real_user(:admin)
- admin.should be_a CanTango::Ability::Scope
- admin.ability.user.name.should == 'admin'
- end
end
-end
-
-
-
+end
\ No newline at end of file