summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-30 17:01:22 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-30 17:01:22 +0000
commit4f0bfdb500b7f72a8e817d1224eaba6ed46204bc (patch)
tree5b1daaaf1a15aa659190288bd3fc23cead46f591 /spec/models/user_spec.rb
parent76e36dd253229d580f2c6336a77e5fc403fe90c3 (diff)
parent4967c087862e5c7c5009605000380d4451ce07ec (diff)
downloadgitlab-ce-4f0bfdb500b7f72a8e817d1224eaba6ed46204bc.tar.gz
Merge branch 'strong-parameters' into 'master'
Strong parameters Replace protected_attributes with strong parameters. Fixes #1340
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb60
1 files changed, 11 insertions, 49 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 0a665b7defb..a36b57a95de 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -65,8 +65,6 @@ describe User do
end
describe "Mass assignment" do
- it { should_not allow_mass_assignment_of(:projects_limit) }
- it { should allow_mass_assignment_of(:projects_limit).as(:admin) }
end
describe 'validations' do
@@ -243,59 +241,23 @@ describe User do
it { user.first_name.should == 'John' }
end
- describe 'without defaults' do
+ describe 'with 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
- 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
- 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, can_create_team: true, theme_id: Gitlab::Theme::BASIC}, as: :admin) }
-
- 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.can_create_group.should be_true
- user.theme_id.should == Gitlab::Theme::BASIC
- end
+ 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
- context 'as user' do
- describe 'with defaults' do
- let(:user) { User.build_user }
+ describe 'with default overrides' do
+ 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
- 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
+ it "should apply defaults to user" do
+ user.projects_limit.should == 123
+ user.can_create_group.should be_false
+ user.theme_id.should == Gitlab::Theme::BASIC
end
end
end