Skip to content
Snippets Groups Projects
Commit 83efcabc authored by Nihad Abbasov's avatar Nihad Abbasov
Browse files

set activerecord whitelist_attributes to true

parent 4629cc44
No related branches found
No related tags found
2 merge requests!1567set activerecord whitelist_attributes to true [2],!1566set activerecord whitelist_attributes to true
Loading
Loading
@@ -7,6 +7,11 @@ describe Note do
it { should belong_to(:author).class_name('User') }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:author) }
it { should_not allow_mass_assignment_of(:author_id) }
end
describe "Validation" do
it { should validate_presence_of(:note) }
it { should validate_presence_of(:project) }
Loading
Loading
Loading
Loading
@@ -17,6 +17,11 @@ describe Project do
it { should have_many(:protected_branches).dependent(:destroy) }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:owner_id) }
it { should_not allow_mass_assignment_of(:private_flag) }
end
describe "Validation" do
let!(:project) { create(:project) }
 
Loading
Loading
Loading
Loading
@@ -5,6 +5,10 @@ describe ProtectedBranch do
it { should belong_to(:project) }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:project_id) }
end
describe 'Validation' do
it { should validate_presence_of(:project_id) }
it { should validate_presence_of(:name) }
Loading
Loading
Loading
Loading
@@ -7,6 +7,11 @@ describe Snippet do
it { should have_many(:notes).dependent(:destroy) }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:author_id) }
it { should_not allow_mass_assignment_of(:project_id) }
end
describe "Validation" do
it { should validate_presence_of(:author_id) }
it { should validate_presence_of(:project_id) }
Loading
Loading
Loading
Loading
@@ -15,6 +15,11 @@ describe User do
it { should have_many(:assigned_merge_requests).dependent(:destroy) }
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
it { should validate_presence_of(:projects_limit) }
it { should validate_numericality_of(:projects_limit) }
Loading
Loading
@@ -73,30 +78,4 @@ describe User do
user.authentication_token.should_not be_blank
end
end
describe "attributes can be changed by a regular user" do
before do
@user = Factory :user
@user.update_attributes(skype: "testskype", linkedin: "testlinkedin")
end
it { @user.skype.should == 'testskype' }
it { @user.linkedin.should == 'testlinkedin' }
end
describe "attributes that shouldn't be changed by a regular user" do
before do
@user = Factory :user
@user.update_attributes(projects_limit: 50)
end
it { @user.projects_limit.should_not == 50 }
end
describe "attributes can be changed by an admin user" do
before do
@admin_user = Factory :admin
@admin_user.update_attributes({ skype: "testskype", projects_limit: 50 }, as: :admin)
end
it { @admin_user.skype.should == 'testskype' }
it { @admin_user.projects_limit.should == 50 }
end
end
Loading
Loading
@@ -6,6 +6,10 @@ describe UsersProject do
it { should belong_to(:user) }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:project_id) }
end
describe "Validation" do
let!(:users_project) { create(:users_project) }
 
Loading
Loading
Loading
Loading
@@ -5,6 +5,10 @@ describe ProjectHook do
it { should belong_to :project }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:project_id) }
end
describe "Validations" do
it { should validate_presence_of(:url) }
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,11 @@ describe Wiki do
it { should have_many(:notes).dependent(:destroy) }
end
 
describe "Mass assignment" do
it { should_not allow_mass_assignment_of(:project_id) }
it { should_not allow_mass_assignment_of(:user_id) }
end
describe "Validation" do
it { should validate_presence_of(:title) }
it { should ensure_length_of(:title).is_within(1..250) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment