Refactor user to admin and api user

This commit is contained in:
Martin Lensment 2015-02-13 16:17:06 +02:00
parent f3215680d5
commit 037cb57e00
34 changed files with 551 additions and 551 deletions

View file

@ -1,10 +1,10 @@
require 'rails_helper'
require 'cancan/matchers'
describe User do
describe AdminUser do
context 'with invalid attribute' do
before :all do
@user = User.new
@user = AdminUser.new
end
it 'should not be valid' do
@ -24,7 +24,7 @@ describe User do
context 'with valid attributes' do
before :all do
@user = Fabricate(:user)
@user = Fabricate(:admin_user)
end
it 'should be valid' do
@ -33,7 +33,7 @@ describe User do
end
# it 'should be valid twice' do
# @user = Fabricate(:user)
# @user = Fabricate(:admin_user)
# @user.valid?
# @user.errors.full_messages.should match_array([])
# end
@ -54,7 +54,7 @@ describe User do
# let(:user) { nil }
# context 'when user is admin' do
# let(:user) { Fabricate(:user) }
# let(:user) { Fabricate(:admin_user) }
# it { should be_able_to(:manage, Domain.new) }
# it { should be_able_to(:manage, Contact.new) }

View file

@ -73,14 +73,14 @@ describe Domain do
it 'should return api_creator when created by api user' do
with_versioning do
@user = Fabricate(:user)
@user = Fabricate(:admin_user)
@api_user = Fabricate(:api_user)
@user.id.should == 1
@api_user.id.should == 1
::PaperTrail.whodunnit = '1-api-testuser'
@api_user.id.should == 2
::PaperTrail.whodunnit = '2-api-testuser'
@domain = Fabricate(:domain)
@domain.creator_str.should == '1-api-testuser'
@domain.creator_str.should == '2-api-testuser'
@domain.creator.should == @api_user
@domain.creator.should_not == @user
@ -89,14 +89,14 @@ describe Domain do
it 'should return api_creator when created by api user' do
with_versioning do
@user = Fabricate(:user)
@user = Fabricate(:admin_user)
@api_user = Fabricate(:api_user)
@user.id.should == 2
@api_user.id.should == 2
::PaperTrail.whodunnit = '2-testuser'
@user.id.should == 3
@api_user.id.should == 4
::PaperTrail.whodunnit = '3-testuser'
@domain = Fabricate(:domain)
@domain.creator_str.should == '2-testuser'
@domain.creator_str.should == '3-testuser'
@domain.creator.should == @user
@domain.creator.should_not == @api_user