Fix user model specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
8daa69a3eb
commit
13f017f01b
|
@ -241,19 +241,9 @@ describe User do
|
||||||
it { user.first_name.should == 'John' }
|
it { user.first_name.should == 'John' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'without defaults' do
|
describe 'with defaults' do
|
||||||
let(:user) { User.new }
|
let(:user) { User.new }
|
||||||
|
|
||||||
it "should not apply defaults to user" do
|
|
||||||
user.projects_limit.should == 10
|
|
||||||
user.can_create_group.should be_true
|
|
||||||
user.theme_id.should == Gitlab::Theme::BASIC
|
|
||||||
end
|
|
||||||
end
|
|
||||||
context 'as admin' do
|
|
||||||
describe 'with defaults' do
|
|
||||||
let(:user) { User.build_user({}, as: :admin) }
|
|
||||||
|
|
||||||
it "should apply defaults to user" do
|
it "should apply defaults to user" do
|
||||||
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
|
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
|
||||||
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
|
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
|
||||||
|
@ -262,42 +252,16 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with default overrides' do
|
describe 'with default overrides' do
|
||||||
let(:user) { User.build_user({projects_limit: 123, can_create_group: true, can_create_team: true, theme_id: Gitlab::Theme::BASIC}, as: :admin) }
|
let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true, theme_id: Gitlab::Theme::BASIC) }
|
||||||
|
|
||||||
it "should apply defaults to user" do
|
it "should apply defaults to user" do
|
||||||
Gitlab.config.gitlab.default_projects_limit.should_not == 123
|
|
||||||
Gitlab.config.gitlab.default_can_create_group.should_not be_true
|
|
||||||
Gitlab.config.gitlab.default_theme.should_not == Gitlab::Theme::BASIC
|
|
||||||
user.projects_limit.should == 123
|
user.projects_limit.should == 123
|
||||||
user.can_create_group.should be_true
|
user.can_create_group.should be_false
|
||||||
user.theme_id.should == Gitlab::Theme::BASIC
|
user.theme_id.should == Gitlab::Theme::BASIC
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as user' do
|
|
||||||
describe 'with defaults' do
|
|
||||||
let(:user) { User.build_user }
|
|
||||||
|
|
||||||
it "should apply defaults to user" do
|
|
||||||
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
|
|
||||||
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
|
|
||||||
user.theme_id.should == Gitlab.config.gitlab.default_theme
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with default overrides' do
|
|
||||||
let(:user) { User.build_user(projects_limit: 123, can_create_group: true, theme_id: Gitlab::Theme::BASIC) }
|
|
||||||
|
|
||||||
it "should apply defaults to user" do
|
|
||||||
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
|
|
||||||
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
|
|
||||||
user.theme_id.should == Gitlab.config.gitlab.default_theme
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'search' do
|
describe 'search' do
|
||||||
let(:user1) { create(:user, username: 'James', email: 'james@testing.com') }
|
let(:user1) { create(:user, username: 'James', email: 'james@testing.com') }
|
||||||
let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') }
|
let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') }
|
||||||
|
|
Loading…
Reference in New Issue