summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/comment_test.rb39
1 files changed, 30 insertions, 9 deletions
diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb
index 4b07d20..fe5abf7 100644
--- a/test/unit/comment_test.rb
+++ b/test/unit/comment_test.rb
@@ -19,17 +19,17 @@
require File.dirname(__FILE__) + '/../test_helper'
-class CommentTest < ActiveSupport::TestCase
-
+class CommentTest < ActiveSupport::TestCase
+
should_validate_presence_of :target, :user_id, :project_id
-
+
context "message notifications" do
setup do
@merge_request = merge_requests(:moes_to_johans_open)
@merge_request.user = users(:moe)
@merge_request.save!
end
-
+
should "be able to notify the creator of the target about a new comment" do
comment = @merge_request.comments.new({
:body => "need more cowbell",
@@ -39,8 +39,10 @@ class CommentTest < ActiveSupport::TestCase
assert_difference("@merge_request.user.received_messages.count") do
comment.save!
end
+ msg = @merge_request.user.received_messages.first
+ assert_equal "johan commented on your merge request", msg.subject
end
-
+
should "not notify the target.user if it's the one who commented" do
comment = @merge_request.comments.new({
:body => "need more cowbell",
@@ -64,6 +66,25 @@ class CommentTest < ActiveSupport::TestCase
assert_difference("@merge_request.user.received_messages.count") do
comment.save!
end
+ msg = @merge_request.user.received_messages.first
+ assert_equal "johan commented on your merge request", msg.subject
+ end
+
+ should "notify creators about MergeRequestVersion state changes" do
+ @merge_request.build_new_version
+ @merge_request.save!
+ assert @merge_request.versions.count >= 1
+ comment = @merge_request.versions.last.comments.new({
+ :body => "off by one",
+ :project => projects(:johans),
+ })
+ comment.state = "Huzzah"
+ comment.user = users(:johan)
+ assert_difference("@merge_request.user.received_messages.count") do
+ comment.save!
+ end
+ msg = @merge_request.user.received_messages.first
+ assert msg.body.include?("The status of your merge request is now Huzzah"), msg.body
end
end
@@ -74,7 +95,7 @@ class CommentTest < ActiveSupport::TestCase
assert !@comment.applies_to_line_numbers?
end
end
-
+
context 'State change' do
should 'be a list of previous and new state' do
@merge_request = merge_requests(:moes_to_johans_open)
@@ -85,7 +106,7 @@ class CommentTest < ActiveSupport::TestCase
assert_equal ['Before', 'After'], @comment.state_change
assert_equal 'After', @merge_request.reload.status_tag.to_s
end
-
+
should 'change the state of its target' do
@merge_request = merge_requests(:moes_to_johans_open)
@comment = @merge_request.comments.new(:body => 'PDI', :project => projects(:johans))
@@ -107,7 +128,7 @@ class CommentTest < ActiveSupport::TestCase
assert @comment.save
assert_equal 'Before', @merge_request.reload.status_tag.to_s
end
-
+
should 'know of previous and new states' do
comment = Comment.new
assert_nil comment.state_changed_from
@@ -208,7 +229,7 @@ class CommentTest < ActiveSupport::TestCase
assert_equal "2-3", @comment.last_line_number
assert_equal 0, @comment.number_of_lines
assert_equal "2-3:2-3+0", @comment.lines
- end
+ end
end
context "On commits, with context" do