diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 89337f716..6390e81f9 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -34,7 +34,7 @@ class Projects::PullRequestsController < Projects::BaseController to_project = find_destination_project authorize to_project, :show? - @pull = to_project.pull_requests.new pull_params + @pull = to_project.pull_requests.build pull_params @issue = @pull.issue @pull.issue.assignee_id = (params[:issue] || {})[:assignee_id] if policy(to_project).write? @pull.issue.user, @pull.issue.project, @pull.from_project = current_user, to_project, @project @@ -131,7 +131,7 @@ class Projects::PullRequestsController < Projects::BaseController end def pull_params - @pull_params ||= params[:pull_request].presence + @pull_params ||= subject_params(PullRequest).presence end def json_for_autocomplete_base items diff --git a/app/policies/pull_request_policy.rb b/app/policies/pull_request_policy.rb index 4133cb491..0d7e3e9c8 100644 --- a/app/policies/pull_request_policy.rb +++ b/app/policies/pull_request_policy.rb @@ -29,10 +29,9 @@ class PullRequestPolicy < ApplicationPolicy %i( body from_ref - issue_attributes title to_ref - ) + ) + [ issue_attributes: %i(title body) ] end end diff --git a/spec/controllers/projects/pull_requests_controller_spec.rb b/spec/controllers/projects/pull_requests_controller_spec.rb index 58c06317a..bd2716b77 100644 --- a/spec/controllers/projects/pull_requests_controller_spec.rb +++ b/spec/controllers/projects/pull_requests_controller_spec.rb @@ -66,7 +66,7 @@ shared_examples_for 'pull request user with project reader rights' do it "should create pull request to the same project" do @parent = FactoryGirl.create(:project) - @project.update_attributes({parent_id: @parent}, without_protection: true) + @project.update_attributes(parent_id: @parent) expect do post :create, @create_params @@ -77,7 +77,7 @@ shared_examples_for 'pull request user with project reader rights' do it "should create pull request to the parent project" do @parent = FactoryGirl.create(:project_with_commit) - @project.update_attributes({parent_id: @parent}, without_protection: true) + @project.update_attributes(parent_id: @parent) expect do post :create, @create_params.merge({to_project: @parent.name_with_owner})