Commit 05c9ab94 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor-author-id-of-changes' into 'master'

Remove author_id_of_changes

To prevent confusion because we already have `current_user`
parents 285ed337 cce80d04
......@@ -76,7 +76,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def update
@issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id))
@issue.update_attributes(params[:issue])
@issue.reset_events_cache
respond_to do |format|
......
......@@ -109,7 +109,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
params[:merge_request].delete(:source_project_id)
params[:merge_request].delete(:target_project_id)
if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id))
if @merge_request.update_attributes(params[:merge_request])
@merge_request.reset_events_cache
respond_to do |format|
......
......@@ -38,7 +38,6 @@ class Projects::MilestonesController < Projects::ApplicationController
def create
@milestone = @project.milestones.new(params[:milestone])
@milestone.author_id_of_changes = current_user.id
if @milestone.save
redirect_to project_milestone_path(@project, @milestone)
......@@ -48,7 +47,7 @@ class Projects::MilestonesController < Projects::ApplicationController
end
def update
@milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id))
@milestone.update_attributes(params[:milestone])
respond_to do |format|
format.js
......
......@@ -37,8 +37,6 @@ module Issuable
allow_nil: true,
prefix: true
attr_accessor :author_id_of_changes
attr_mentionable :title, :description
end
......
......@@ -30,8 +30,7 @@ class Issue < ActiveRecord::Base
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
attr_accessible :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :author_id_of_changes,
:state_event
:milestone_id, :label_list, :state_event
acts_as_taggable_on :labels
......
......@@ -38,7 +38,7 @@ class MergeRequest < ActiveRecord::Base
delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil
attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event, :description
attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :state_event, :description
attr_accessor :should_remove_source_branch
......
......@@ -16,8 +16,7 @@
class Milestone < ActiveRecord::Base
include InternalId
attr_accessible :title, :description, :due_date, :state_event, :author_id_of_changes
attr_accessor :author_id_of_changes
attr_accessible :title, :description, :due_date, :state_event
belongs_to :project
has_many :issues
......@@ -89,6 +88,6 @@ class Milestone < ActiveRecord::Base
end
def author_id
author_id_of_changes
nil
end
end
......@@ -2,8 +2,6 @@ class ActivityObserver < BaseObserver
observe :issue, :note, :milestone
def after_create(record)
event_author_id = record.author_id
if record.kind_of?(Note)
# Skip system notes, like status changes and cross-references.
return true if record.system?
......@@ -12,9 +10,7 @@ class ActivityObserver < BaseObserver
return true if record.noteable_type.blank?
end
if event_author_id
create_event(record, Event.determine_action(record))
end
create_event(record, Event.determine_action(record)) if current_user
end
def after_close(record, transition)
......
......@@ -9,11 +9,10 @@ module MergeRequests
merge_request.lock
if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message)
merge_request.author_id_of_changes = current_user.id
merge_request.merge
notification.merge_mr(merge_request, current_user)
create_merge_event(merge_request)
create_merge_event(merge_request, current_user)
execute_project_hooks(merge_request)
true
......
......@@ -7,13 +7,13 @@ module MergeRequests
NotificationService.new
end
def create_merge_event(merge_request)
def create_merge_event(merge_request, current_user)
Event.create(
project: merge_request.target_project,
target_id: merge_request.id,
target_type: merge_request.class.name,
action: Event::MERGED,
author_id: merge_request.author_id_of_changes
author_id: current_user.id
)
end
......
......@@ -7,11 +7,10 @@ module MergeRequests
# to target branch
class MergeService < BaseMergeService
def execute(merge_request, current_user, commit_message)
merge_request.author_id_of_changes = current_user.id
merge_request.merge
notification.merge_mr(merge_request, current_user)
create_merge_event(merge_request)
create_merge_event(merge_request, current_user)
execute_project_hooks(merge_request)
true
......
......@@ -25,11 +25,6 @@ describe Issue, "Issuable" do
it { described_class.should respond_to(:assigned) }
end
it "has an :author_id_of_changes accessor" do
issue.should respond_to(:author_id_of_changes)
issue.should respond_to(:author_id_of_changes=)
end
describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable issue") }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment