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 ...@@ -76,7 +76,7 @@ class Projects::IssuesController < Projects::ApplicationController
end end
def update def update
@issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id)) @issue.update_attributes(params[:issue])
@issue.reset_events_cache @issue.reset_events_cache
respond_to do |format| respond_to do |format|
......
...@@ -109,7 +109,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -109,7 +109,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
params[:merge_request].delete(:source_project_id) params[:merge_request].delete(:source_project_id)
params[:merge_request].delete(:target_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 @merge_request.reset_events_cache
respond_to do |format| respond_to do |format|
......
...@@ -38,7 +38,6 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -38,7 +38,6 @@ class Projects::MilestonesController < Projects::ApplicationController
def create def create
@milestone = @project.milestones.new(params[:milestone]) @milestone = @project.milestones.new(params[:milestone])
@milestone.author_id_of_changes = current_user.id
if @milestone.save if @milestone.save
redirect_to project_milestone_path(@project, @milestone) redirect_to project_milestone_path(@project, @milestone)
...@@ -48,7 +47,7 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -48,7 +47,7 @@ class Projects::MilestonesController < Projects::ApplicationController
end end
def update def update
@milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id)) @milestone.update_attributes(params[:milestone])
respond_to do |format| respond_to do |format|
format.js format.js
......
...@@ -37,8 +37,6 @@ module Issuable ...@@ -37,8 +37,6 @@ module Issuable
allow_nil: true, allow_nil: true,
prefix: true prefix: true
attr_accessor :author_id_of_changes
attr_mentionable :title, :description attr_mentionable :title, :description
end end
......
...@@ -30,8 +30,7 @@ class Issue < ActiveRecord::Base ...@@ -30,8 +30,7 @@ class Issue < ActiveRecord::Base
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
attr_accessible :title, :assignee_id, :position, :description, attr_accessible :title, :assignee_id, :position, :description,
:milestone_id, :label_list, :author_id_of_changes, :milestone_id, :label_list, :state_event
:state_event
acts_as_taggable_on :labels acts_as_taggable_on :labels
......
...@@ -38,7 +38,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -38,7 +38,7 @@ class MergeRequest < ActiveRecord::Base
delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil 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 attr_accessor :should_remove_source_branch
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
class Milestone < ActiveRecord::Base class Milestone < ActiveRecord::Base
include InternalId include InternalId
attr_accessible :title, :description, :due_date, :state_event, :author_id_of_changes attr_accessible :title, :description, :due_date, :state_event
attr_accessor :author_id_of_changes
belongs_to :project belongs_to :project
has_many :issues has_many :issues
...@@ -89,6 +88,6 @@ class Milestone < ActiveRecord::Base ...@@ -89,6 +88,6 @@ class Milestone < ActiveRecord::Base
end end
def author_id def author_id
author_id_of_changes nil
end end
end end
...@@ -2,8 +2,6 @@ class ActivityObserver < BaseObserver ...@@ -2,8 +2,6 @@ class ActivityObserver < BaseObserver
observe :issue, :note, :milestone observe :issue, :note, :milestone
def after_create(record) def after_create(record)
event_author_id = record.author_id
if record.kind_of?(Note) if record.kind_of?(Note)
# Skip system notes, like status changes and cross-references. # Skip system notes, like status changes and cross-references.
return true if record.system? return true if record.system?
...@@ -12,9 +10,7 @@ class ActivityObserver < BaseObserver ...@@ -12,9 +10,7 @@ class ActivityObserver < BaseObserver
return true if record.noteable_type.blank? return true if record.noteable_type.blank?
end end
if event_author_id create_event(record, Event.determine_action(record)) if current_user
create_event(record, Event.determine_action(record))
end
end end
def after_close(record, transition) def after_close(record, transition)
......
...@@ -9,11 +9,10 @@ module MergeRequests ...@@ -9,11 +9,10 @@ module MergeRequests
merge_request.lock merge_request.lock
if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message) if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message)
merge_request.author_id_of_changes = current_user.id
merge_request.merge merge_request.merge
notification.merge_mr(merge_request, current_user) notification.merge_mr(merge_request, current_user)
create_merge_event(merge_request) create_merge_event(merge_request, current_user)
execute_project_hooks(merge_request) execute_project_hooks(merge_request)
true true
......
...@@ -7,13 +7,13 @@ module MergeRequests ...@@ -7,13 +7,13 @@ module MergeRequests
NotificationService.new NotificationService.new
end end
def create_merge_event(merge_request) def create_merge_event(merge_request, current_user)
Event.create( Event.create(
project: merge_request.target_project, project: merge_request.target_project,
target_id: merge_request.id, target_id: merge_request.id,
target_type: merge_request.class.name, target_type: merge_request.class.name,
action: Event::MERGED, action: Event::MERGED,
author_id: merge_request.author_id_of_changes author_id: current_user.id
) )
end end
......
...@@ -7,11 +7,10 @@ module MergeRequests ...@@ -7,11 +7,10 @@ module MergeRequests
# to target branch # to target branch
class MergeService < BaseMergeService class MergeService < BaseMergeService
def execute(merge_request, current_user, commit_message) def execute(merge_request, current_user, commit_message)
merge_request.author_id_of_changes = current_user.id
merge_request.merge merge_request.merge
notification.merge_mr(merge_request, current_user) notification.merge_mr(merge_request, current_user)
create_merge_event(merge_request) create_merge_event(merge_request, current_user)
execute_project_hooks(merge_request) execute_project_hooks(merge_request)
true true
......
...@@ -25,11 +25,6 @@ describe Issue, "Issuable" do ...@@ -25,11 +25,6 @@ describe Issue, "Issuable" do
it { described_class.should respond_to(:assigned) } it { described_class.should respond_to(:assigned) }
end 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 describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable issue") } 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