Replace changeset_comments fixtures with a factory.
There's little point in testing ChangesetComment.count so I've removed that test.
This commit is contained in:
parent
c2e12ed77d
commit
a91e50d308
7 changed files with 32 additions and 48 deletions
|
@ -75,6 +75,9 @@ class BrowseControllerTest < ActionController::TestCase
|
|||
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
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require "changeset_controller"
|
|||
|
||||
class ChangesetControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
fixtures :changeset_comments, :changesets_subscribers
|
||||
fixtures :changesets_subscribers
|
||||
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
|
@ -197,6 +197,7 @@ class ChangesetControllerTest < ActionController::TestCase
|
|||
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"
|
||||
|
@ -2149,7 +2150,7 @@ EOF
|
|||
# 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
|
||||
|
@ -2174,7 +2175,7 @@ EOF
|
|||
##
|
||||
# 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")
|
||||
|
@ -2188,7 +2189,7 @@ EOF
|
|||
# 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
|
||||
|
@ -2213,7 +2214,7 @@ EOF
|
|||
##
|
||||
# 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")
|
||||
|
@ -2226,6 +2227,8 @@ EOF
|
|||
##
|
||||
# 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
|
||||
|
|
12
test/factories/changeset_comments.rb
Normal file
12
test/factories/changeset_comments.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
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
|
31
test/fixtures/changeset_comments.yml
vendored
31
test/fixtures/changeset_comments.yml
vendored
|
@ -1,31 +0,0 @@
|
|||
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
|
|
@ -1,7 +1,7 @@
|
|||
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
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
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?
|
||||
|
@ -20,7 +16,7 @@ class ChangesetCommentTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_does_not_accept_invalid_changeset
|
||||
comment = changeset_comments(:normal_comment_1)
|
||||
comment = create(:changeset_comment)
|
||||
|
||||
comment.changeset = nil
|
||||
assert !comment.valid?
|
||||
|
@ -30,13 +26,14 @@ class ChangesetCommentTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
||||
|
@ -47,13 +44,13 @@ class ChangesetCommentTest < ActiveSupport::TestCase
|
|||
"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
|
||||
|
|
|
@ -14,7 +14,7 @@ module ActiveSupport
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue