summaryrefslogtreecommitdiffstats
path: root/app/models/merge_request.rb
diff options
context:
space:
mode:
authorMarius Mathiesen <marius.mathiesen@gmail.com>2009-06-15 14:45:44 +0200
committerMarius Mathiesen <marius.mathiesen@gmail.com>2009-06-24 12:20:33 +0200
commit30646e5fe84ceb59fea14a75e1e5ddf02a180fb3 (patch)
tree02c1702d9a8ae5c07bafbb74b95d4058446c0070 /app/models/merge_request.rb
parentd4a271ef7971d79ff3a1d6b4380c028915db2bd6 (diff)
downloadgitorious-mainline-outdated-30646e5fe84ceb59fea14a75e1e5ddf02a180fb3.zip
gitorious-mainline-outdated-30646e5fe84ceb59fea14a75e1e5ddf02a180fb3.tar.gz
gitorious-mainline-outdated-30646e5fe84ceb59fea14a75e1e5ddf02a180fb3.tar.bz2
Make some status tags "sticky", that is change the state machinestate.
- Add a list of status tags - Also remove the update_status method in MergeRequest, as this wasn't being used - Add tests for changing the status through comments
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r--app/models/merge_request.rb35
1 files changed, 24 insertions, 11 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index a56a91f..bc70ff3 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -162,6 +162,19 @@ class MergeRequest < ActiveRecord::Base
end
end
+ def status_tag=(s)
+ case s
+ when 'merged'
+ self.status = STATUS_MERGED
+ when 'rejected'
+ self.status = STATUS_REJECTED
+ when 'in_verification'
+ self.status = STATUS_VERIFYING
+ end
+ write_attribute(:status_tag, s)
+ save
+ end
+
# Returns a hash (for the view) of labels and event names for next states
# TODO: Obviously, putting the states and transitions inside a map is not all that DRY,
# but the state machine does not have a one-to-one relationship between states and events
@@ -387,17 +400,6 @@ class MergeRequest < ActiveRecord::Base
save
end
- def update_status(options)
- user = options[:user]
- comment = comments.build(:body => options[:comment], :user => user)
- if resolvable_by?(user) && new_tag = options[:tag]
- comment.state_change = [status_tag, new_tag]
- self.status_tag = new_tag
- end
- comment.save
- save
- end
-
def valid_oauth_credentials?
response = access_token.get("/")
return Net::HTTPSuccess === response
@@ -441,5 +443,16 @@ class MergeRequest < ActiveRecord::Base
else
$stderr.puts "WARNING: Merge request #{id} lacks target or source repository"
end
+ migrate_decision_to_comment
+ end
+
+ # Another one time migration:
+ # If we have a reason (that is someone who can resolve us) we will create a comment with this as body and set the state to be the current +status_string+
+ def migrate_decision_to_comment
+ unless reason.blank?
+ c = comments.build(:body => reason, :user => updated_by, :project => target_repository.project)
+ c.state = status_string
+ c.save!
+ end
end
end