From e0e88cddd805a1aa5f467dcea826c24a64187df0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Sat, 14 Sep 2013 22:01:31 +0300 Subject: [PATCH] Fix tests --- spec/models/user_spec.rb | 20 +++++++++++++------- spec/requests/api/users_spec.rb | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 330d22cf96..79915daa46 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -209,6 +209,7 @@ describe User do describe 'without defaults' do let(:user) { User.new } + it "should not apply defaults to user" do user.projects_limit.should == 10 user.can_create_group.should be_true @@ -218,19 +219,21 @@ describe User do context 'as admin' do describe 'with defaults' do let(:user) { User.build_user({}, as: :admin) } + it "should apply defaults to user" do user.projects_limit.should == 42 user.can_create_group.should be_false - user.theme_id.should == Gitlab::Theme::BASIC + user.theme_id.should == Gitlab::Theme::MARS end end 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::MARS}, as: :admin) } + let(:user) { User.build_user({projects_limit: 123, can_create_group: true, can_create_team: true, theme_id: Gitlab::Theme::BASIC}, as: :admin) } + it "should apply defaults to user" do user.projects_limit.should == 123 user.can_create_group.should be_true - user.theme_id.should == Gitlab::Theme::MARS + user.theme_id.should == Gitlab::Theme::BASIC end end end @@ -238,26 +241,29 @@ describe User do context 'as user' do describe 'with defaults' do let(:user) { User.build_user } + it "should apply defaults to user" do user.projects_limit.should == 42 user.can_create_group.should be_false - user.theme_id.should == Gitlab::Theme::BASIC + user.theme_id.should == Gitlab::Theme::MARS end end describe 'with default overrides' do - let(:user) { User.build_user(projects_limit: 123, can_create_group: true, theme_id: Gitlab::Theme::MARS) } + 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 == 42 user.can_create_group.should be_false - user.theme_id.should == Gitlab::Theme::BASIC + user.theme_id.should == Gitlab::Theme::MARS end end end end describe 'by_username_or_id' do - let(:user1){create(:user, username: 'foo')} + let(:user1) { create(:user, username: 'foo') } + it "should get the correct user" do User.by_username_or_id(user1.id).should == user1 User.by_username_or_id('foo').should == user1 diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index e42c0567ef..2fced3ec94 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -66,7 +66,7 @@ describe API::API do }.to change { User.count }.by(1) user = User.find_by_username(attr[:username]) user.projects_limit.should == limit - user.theme_id.should == Gitlab::Theme::BASIC + user.theme_id.should == Gitlab::Theme::MARS Gitlab.config.gitlab.unstub(:default_projects_limit) end -- 2.30.9