From 8db3920c01dfa4cf6c83afd67418bab8cb785bac Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Fri, 15 Feb 2013 12:27:13 +0400 Subject: [PATCH] State renamed to merge_status --- app/controllers/merge_requests_controller.rb | 4 ++-- app/models/merge_request.rb | 18 +++++++++--------- app/views/merge_requests/_show.html.haml | 4 ++-- ...ename_state_to_merge_status_in_milestone.rb | 5 +++++ spec/models/merge_request_spec.rb | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20130214154045_rename_state_to_merge_status_in_milestone.rb diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index ab6bf595..c1cf66d5 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -73,9 +73,9 @@ class MergeRequestsController < ProjectResourceController if @merge_request.unchecked? @merge_request.check_if_can_be_merged end - render json: {state: @merge_request.human_state} + render json: {merge_status: @merge_request.human_merge_status} rescue Gitlab::SatelliteNotExistError - render json: {state: :no_satellite} + render json: {merge_status: :no_satellite} end def automerge diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 345b8d6e..cf4f75aa 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -15,7 +15,7 @@ # st_commits :text(2147483647) # st_diffs :text(2147483647) # merged :boolean default(FALSE), not null -# state :integer default(1), not null +# merge_status :integer default(1), not null # milestone_id :integer # @@ -51,13 +51,13 @@ class MergeRequest < ActiveRecord::Base where("milestone_id = :milestone_id", milestone_id: milestone) end - def human_state - states = { + def human_merge_status + merge_statuses = { CAN_BE_MERGED => "can_be_merged", CANNOT_BE_MERGED => "cannot_be_merged", UNCHECKED => "unchecked" } - states[self.state] + merge_statuses[self.merge_status] end def validate_branches @@ -72,20 +72,20 @@ class MergeRequest < ActiveRecord::Base end def unchecked? - state == UNCHECKED + merge_status == UNCHECKED end def mark_as_unchecked - self.state = UNCHECKED + self.merge_status = UNCHECKED self.save end def can_be_merged? - state == CAN_BE_MERGED + merge_status == CAN_BE_MERGED end def check_if_can_be_merged - self.state = if Gitlab::Satellite::MergeAction.new(self.author, self).can_be_merged? + self.merge_status = if Gitlab::Satellite::MergeAction.new(self.author, self).can_be_merged? CAN_BE_MERGED else CANNOT_BE_MERGED @@ -160,7 +160,7 @@ class MergeRequest < ActiveRecord::Base end def mark_as_unmergable - self.state = CANNOT_BE_MERGED + self.merge_status = CANNOT_BE_MERGED self.save end diff --git a/app/views/merge_requests/_show.html.haml b/app/views/merge_requests/_show.html.haml index cefd33c0..ae2cfe92 100644 --- a/app/views/merge_requests/_show.html.haml +++ b/app/views/merge_requests/_show.html.haml @@ -29,10 +29,10 @@ $(function(){ merge_request = new MergeRequest({ url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}", - check_enable: #{@merge_request.state == MergeRequest::UNCHECKED ? "true" : "false"}, + check_enable: #{@merge_request.merge_status == MergeRequest::UNCHECKED ? "true" : "false"}, url_to_ci_check: "#{ci_status_project_merge_request_path(@project, @merge_request)}", ci_enable: #{@project.gitlab_ci? ? "true" : "false"}, - current_state: "#{@merge_request.human_state}", + current_status: "#{@merge_request.human_merge_status}", action: "#{controller.action_name}" }); }); diff --git a/db/migrate/20130214154045_rename_state_to_merge_status_in_milestone.rb b/db/migrate/20130214154045_rename_state_to_merge_status_in_milestone.rb new file mode 100644 index 00000000..23797fe1 --- /dev/null +++ b/db/migrate/20130214154045_rename_state_to_merge_status_in_milestone.rb @@ -0,0 +1,5 @@ +class RenameStateToMergeStatusInMilestone < ActiveRecord::Migration + def change + rename_column :merge_requests, :state, :merge_status + end +end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 41f4ede5..6f344813 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -15,7 +15,7 @@ # st_commits :text(2147483647) # st_diffs :text(2147483647) # merged :boolean default(FALSE), not null -# state :integer default(1), not null +# merge_status :integer default(1), not null # milestone_id :integer #