end
def test_read_changeset_hidden_comments
+ create_list(:changeset_comment, 3)
+ create(:changeset_comment, :visible => false)
+
browse_check "changeset", changesets(:normal_user_closed_change).id, "browse/changeset"
assert_select "div.changeset-comments ul li", :count => 3
class ChangesetControllerTest < ActionController::TestCase
api_fixtures
- fixtures :changeset_comments, :changesets_subscribers
+ fixtures :changesets_subscribers
##
# test all routes which lead to this controller
assert_select "osm>changeset>discussion>comment", 0
changeset_id = changesets(:normal_user_closed_change).id
+ create_list(:changeset_comment, 3, :changeset_id => changeset_id)
get :read, :id => changeset_id, :include_discussion => true
assert_response :success, "cannot get closed changeset with comments"
# test hide comment fail
def test_hide_comment_fail
# unauthorized
- comment = changeset_comments(:normal_comment_1)
+ comment = create(:changeset_comment)
assert_equal true, comment.visible
post :hide_comment, :id => comment.id
##
# test hide comment succes
def test_hide_comment_success
- comment = changeset_comments(:normal_comment_1)
+ comment = create(:changeset_comment)
assert_equal true, comment.visible
basic_authorization(users(:moderator_user).email, "test")
# test unhide comment fail
def test_unhide_comment_fail
# unauthorized
- comment = changeset_comments(:hidden_comment)
+ comment = create(:changeset_comment, :visible => false)
assert_equal false, comment.visible
post :unhide_comment, :id => comment.id
##
# test unhide comment succes
def test_unhide_comment_success
- comment = changeset_comments(:hidden_comment)
+ comment = create(:changeset_comment, :visible => false)
assert_equal false, comment.visible
basic_authorization(users(:moderator_user).email, "test")
##
# test comments feed
def test_comments_feed
+ create_list(:changeset_comment, 3, :changeset_id => changesets(:normal_user_closed_change).id)
+
get :comments_feed, :format => "rss"
assert_response :success
assert_equal "application/rss+xml", @response.content_type
--- /dev/null
+FactoryGirl.define do
+ factory :changeset_comment do
+ sequence(:body) { |n| "Changeset comment #{n}" }
+ visible true
+
+ # FIXME: needs changeset factory
+ changeset_id 3
+
+ # FIXME: needs user factory
+ author_id 1
+ end
+end
+++ /dev/null
-normal_comment_1:
- id: 1
- changeset_id: 3
- created_at: 2007-01-01 00:00:00
- author_id: 1
- body: 'A comment from a logged-in user'
- visible: true
-
-normal_comment_2:
- id: 2
- changeset_id: 3
- created_at: 2007-02-01 00:00:00
- author_id: 4
- body: 'A comment from another logged-in user'
- visible: true
-
-normal_comment_3:
- id: 4
- changeset_id: 3
- created_at: 2007-02-01 00:00:00
- author_id: 4
- body: 'A comment from another logged-in user'
- visible: true
-
-hidden_comment:
- id: 3
- changeset_id: 3
- created_at: 2007-02-01 00:00:00
- author_id: 4
- body: 'A non-visible comment'
- visible: false
\ No newline at end of file
require "test_helper"
class UserChangesetCommentsTest < ActionDispatch::IntegrationTest
- fixtures :users, :changesets, :changeset_comments
+ fixtures :users, :changesets
# Test 'log in to comment' message for nonlogged in user
def test_log_in_message
require "test_helper"
class ChangesetCommentTest < ActiveSupport::TestCase
- fixtures :changesets, :changeset_comments
-
- def test_changeset_comment_count
- assert_equal 4, ChangesetComment.count
- end
+ fixtures :changesets
# validations
def test_does_not_accept_invalid_author
- comment = changeset_comments(:normal_comment_1)
+ comment = create(:changeset_comment)
comment.author = nil
assert !comment.valid?
end
def test_does_not_accept_invalid_changeset
- comment = changeset_comments(:normal_comment_1)
+ comment = create(:changeset_comment)
comment.changeset = nil
assert !comment.valid?
end
def test_does_not_accept_empty_visible
- comment = changeset_comments(:normal_comment_1)
+ comment = create(:changeset_comment)
comment.visible = nil
assert !comment.valid?
end
def test_comments_of_changeset_count
+ create_list(:changeset_comment, 3, :changeset_id => changesets(:normal_user_closed_change).id)
assert_equal 3, Changeset.find(changesets(:normal_user_closed_change).id).comments.count
end
"foo\ufffebar", "foo\uffffbar"]
ok.each do |body|
- changeset_comment = changeset_comments(:normal_comment_1)
+ changeset_comment = create(:changeset_comment)
changeset_comment.body = body
assert changeset_comment.valid?, "#{body} is invalid, when it should be"
end
bad.each do |body|
- changeset_comment = changeset_comments(:normal_comment_1)
+ changeset_comment = create(:changeset_comment)
changeset_comment.body = body
assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"
end
def self.api_fixtures
# print "setting up the api_fixtures"
fixtures :users, :user_roles, :user_blocks
- fixtures :changesets, :changeset_tags, :changeset_comments
+ fixtures :changesets, :changeset_tags
fixtures :current_nodes, :nodes
set_fixture_class :current_nodes => Node