{ :controller => "diary_comments", :action => "index", :display_name => "username" }
)
assert_routing(
- { :path => "/user/username/diary/1/newcomment", :method => :post },
+ { :path => "/user/username/diary/1/comments", :method => :post },
{ :controller => "diary_comments", :action => "create", :display_name => "username", :id => "1" }
)
assert_routing(
- { :path => "/user/username/diary/1/hidecomment/2", :method => :post },
- { :controller => "diary_comments", :action => "hide", :display_name => "username", :id => "1", :comment => "2" }
+ { :path => "/diary_comments/2/hide", :method => :post },
+ { :controller => "diary_comments", :action => "hide", :comment => "2" }
)
assert_routing(
- { :path => "/user/username/diary/1/unhidecomment/2", :method => :post },
- { :controller => "diary_comments", :action => "unhide", :display_name => "username", :id => "1", :comment => "2" }
+ { :path => "/diary_comments/2/unhide", :method => :post },
+ { :controller => "diary_comments", :action => "unhide", :comment => "2" }
)
get "/user/username/diary/comments/1"
end
end
end
- assert_redirected_to diary_entry_path(entry.user, entry)
+ comment = DiaryComment.last
+ assert_redirected_to diary_entry_path(entry.user, entry, :anchor => "comment#{comment.id}")
email = ActionMailer::Base.deliveries.first
assert_equal [user.email], email.to
assert_equal "[OpenStreetMap] #{other_user.display_name} commented on a diary entry", email.subject
assert_match(/New comment/, email.text_part.decoded)
assert_match(/New comment/, email.html_part.decoded)
ActionMailer::Base.deliveries.clear
- comment = DiaryComment.order(:id).last
assert_equal entry.id, comment.diary_entry_id
assert_equal other_user.id, comment.user_id
assert_equal "New comment", comment.body
end
end
end
- assert_redirected_to diary_entry_path(entry.user, entry)
+ comment = DiaryComment.last
+ assert_redirected_to diary_entry_path(entry.user, entry, :anchor => "comment#{comment.id}")
email = ActionMailer::Base.deliveries.first
assert_equal [user.email], email.to
assert_equal "[OpenStreetMap] #{other_user.display_name} commented on a diary entry", email.subject
assert_match %r{http://example.com/spam}, email.text_part.decoded
assert_match %r{http://example.com/spam}, email.html_part.decoded
ActionMailer::Base.deliveries.clear
- comment = DiaryComment.order(:id).last
assert_equal entry.id, comment.diary_entry_id
assert_equal other_user.id, comment.user_id
assert_equal spammy_text, comment.body
diary_comment = create(:diary_comment, :diary_entry => diary_entry)
# Try without logging in
- post hide_diary_comment_path(user, diary_entry, diary_comment)
+ post hide_diary_comment_path(diary_comment)
assert_response :forbidden
assert DiaryComment.find(diary_comment.id).visible
# Now try as a normal user
session_for(user)
- post hide_diary_comment_path(user, diary_entry, diary_comment)
+ post hide_diary_comment_path(diary_comment)
assert_redirected_to :controller => :errors, :action => :forbidden
assert DiaryComment.find(diary_comment.id).visible
# Try as a moderator
session_for(create(:moderator_user))
- post hide_diary_comment_path(user, diary_entry, diary_comment)
+ post hide_diary_comment_path(diary_comment)
assert_redirected_to diary_entry_path(user, diary_entry)
assert_not DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
- post hide_diary_comment_path(user, diary_entry, diary_comment)
+ post hide_diary_comment_path(diary_comment)
assert_redirected_to diary_entry_path(user, diary_entry)
assert_not DiaryComment.find(diary_comment.id).visible
end
diary_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false)
# Try without logging in
- post unhide_diary_comment_path(user, diary_entry, diary_comment)
+ post unhide_diary_comment_path(diary_comment)
assert_response :forbidden
assert_not DiaryComment.find(diary_comment.id).visible
# Now try as a normal user
session_for(user)
- post unhide_diary_comment_path(user, diary_entry, diary_comment)
+ post unhide_diary_comment_path(diary_comment)
assert_redirected_to :controller => :errors, :action => :forbidden
assert_not DiaryComment.find(diary_comment.id).visible
# Now try as a moderator
session_for(create(:moderator_user))
- post unhide_diary_comment_path(user, diary_entry, diary_comment)
+ post unhide_diary_comment_path(diary_comment)
assert_redirected_to diary_entry_path(user, diary_entry)
assert DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
- post unhide_diary_comment_path(user, diary_entry, diary_comment)
+ post unhide_diary_comment_path(diary_comment)
assert_redirected_to diary_entry_path(user, diary_entry)
assert DiaryComment.find(diary_comment.id).visible
end