diff --git a/app/controllers/api/v1/groups_controller.rb b/app/controllers/api/v1/groups_controller.rb index a701bbdd8..1e2af7252 100644 --- a/app/controllers/api/v1/groups_controller.rb +++ b/app/controllers/api/v1/groups_controller.rb @@ -28,7 +28,8 @@ class Api::V1::GroupsController < Api::V1::BaseController end def create - @group = current_user.own_groups.new(group_params) + @group = current_user.own_groups.new + @group.assign_attributes(group_params) create_subject @group end @@ -50,7 +51,7 @@ class Api::V1::GroupsController < Api::V1::BaseController private def group_params - subject_params(Group) + subject_params(Group, @group) end # Private: before_action hook which loads Group. diff --git a/app/controllers/groups/profile_controller.rb b/app/controllers/groups/profile_controller.rb index 27c409f25..252874dd1 100644 --- a/app/controllers/groups/profile_controller.rb +++ b/app/controllers/groups/profile_controller.rb @@ -43,7 +43,9 @@ class Groups::ProfileController < Groups::BaseController end def create - authorize @group = current_user.own_groups.build(group_params) + @group = current_user.own_groups.new + @group.assign_attributes(group_params) + authorize @group if @group.save flash[:notice] = t('flash.group.saved') redirect_to group_path(@group) @@ -82,7 +84,7 @@ class Groups::ProfileController < Groups::BaseController protected def group_params - subject_params(Group) + subject_params(Group, @group) end def paginate_projects(page) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index b163e8918..e1850d1bd 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -24,13 +24,6 @@ describe Comment do set_commentable_data end - context 'with mass assignment' do - it 'should not be able to update commentable' do - @comment.update_attributes({commentable_type: 'Grit::Commit', commentable_id: 0}) - expect(@comment.reload.commentable).to eq(@issue) - end - end - context 'automatic issue linking' do before(:each) do @same_name_project = FactoryGirl.create(:project, name: @project.name) diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index a59d37889..fbaf15230 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -44,7 +44,7 @@ describe Product do params = {main_script: 'text.sh', project_version: product.project.default_branch} product.update_attributes params.merge(autostart_status: Product::ONCE_A_12_HOURS) FactoryGirl.create :product, params.merge(autostart_status: Product::ONCE_A_DAY) - FactoryGirl.create(:arch, name: 'x86_64') + FactoryGirl.build(:arch, name: 'x86_64').save end it 'should be created only one product_build_list' do