tests: fix forum post votes & wiki page updater tests.
* Move forum post vote tests from test/controllers to test/functional. * Fix forum post vote tests to work with new routes. * Fix obsolete wiki page tests dealing with updater_id.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumPostVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The forum post votes controller" do
|
||||
setup do
|
||||
@user = create(:user)
|
||||
|
||||
as_user do
|
||||
@forum_topic = create(:forum_topic)
|
||||
@forum_post = create(:forum_post, topic: @forum_topic)
|
||||
end
|
||||
end
|
||||
|
||||
should "allow voting" do
|
||||
assert_difference("ForumPostVote.count") do
|
||||
post_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {forum_post_vote: {score: 1}, format: "js"}
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
context "when deleting" do
|
||||
setup do
|
||||
as_user do
|
||||
@forum_post_vote = @forum_post.votes.create(score: 1)
|
||||
end
|
||||
end
|
||||
|
||||
should "allow removal" do
|
||||
assert_difference("ForumPostVote.count", -1) do
|
||||
delete_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {format: "js"}
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -149,20 +149,13 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_redirected_to(artist_path(@artist.id))
|
||||
end
|
||||
|
||||
should "not touch the updater_id and updated_at fields when nothing is changed" do
|
||||
should "not touch the updated_at fields when nothing is changed" do
|
||||
old_timestamp = @wiki_page.updated_at
|
||||
old_updater_id = @wiki_page.updater_id
|
||||
|
||||
travel(1.minute) do
|
||||
as(@another_user) do
|
||||
@artist.update(notes: "testing")
|
||||
end
|
||||
end
|
||||
travel(1.minute)
|
||||
as(@another_user) { @artist.update(notes: "testing") }
|
||||
|
||||
@artist.reload
|
||||
@wiki_page = @artist.wiki_page
|
||||
assert_equal(old_timestamp.to_i, @wiki_page.updated_at.to_i)
|
||||
assert_equal(old_updater_id, @wiki_page.updater_id)
|
||||
assert_equal(old_timestamp.to_i, @artist.reload.wiki_page.updated_at.to_i)
|
||||
end
|
||||
|
||||
context "when renaming an artist" do
|
||||
|
||||
@@ -8,13 +8,32 @@ class ForumPostVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
as(@user) do
|
||||
@forum_topic = create(:forum_topic)
|
||||
@forum_post = create(:forum_post, topic: @forum_topic)
|
||||
@forum_post_vote = create(:forum_post_vote, creator: @user, forum_post: @forum_post)
|
||||
end
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
@forum_post_vote = create(:forum_post_vote, creator: @user, forum_post: @forum_post)
|
||||
get forum_post_votes_path
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
should "allow voting" do
|
||||
assert_difference("ForumPostVote.count") do
|
||||
post_auth forum_post_votes_path(format: :js), @user, params: { forum_post_id: @forum_post.id, forum_post_vote: { score: 1 }}
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
context "when deleting" do
|
||||
should "allow removal" do
|
||||
@forum_post_vote = create(:forum_post_vote, creator: @user, forum_post: @forum_post)
|
||||
assert_difference("ForumPostVote.count", -1) do
|
||||
delete_auth forum_post_vote_path(@forum_post_vote.id, format: :js), @user
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -154,24 +154,16 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
|
||||
@wiki_page.reload
|
||||
assert_equal(true, @wiki_page.is_deleted?)
|
||||
end
|
||||
|
||||
should "record the deleter" do
|
||||
delete_auth wiki_page_path(@wiki_page), @mod
|
||||
@wiki_page.reload
|
||||
assert_equal(@mod.id, @wiki_page.updater_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "revert action" do
|
||||
setup do
|
||||
as_user do
|
||||
@wiki_page = create(:wiki_page, :body => "1")
|
||||
end
|
||||
travel(1.day) do
|
||||
@wiki_page.update(:body => "1 2")
|
||||
end
|
||||
travel(2.days) do
|
||||
@wiki_page.update(:body => "1 2 3")
|
||||
@wiki_page = create(:wiki_page, body: "1")
|
||||
travel(1.day)
|
||||
@wiki_page.update(body: "1 2")
|
||||
travel(2.days)
|
||||
@wiki_page.update(body: "1 2 3")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -101,16 +101,6 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
assert_equal("hot_potato", @wiki_page.title)
|
||||
end
|
||||
|
||||
should "differentiate between updater and creator" do
|
||||
another_user = FactoryBot.create(:user)
|
||||
CurrentUser.scoped(another_user, "127.0.0.1") do
|
||||
@wiki_page.title = "yyy"
|
||||
@wiki_page.save
|
||||
end
|
||||
version = WikiPageVersion.last
|
||||
assert_not_equal(@wiki_page.creator_id, version.updater_id)
|
||||
end
|
||||
|
||||
should "update its dtext links" do
|
||||
@wiki_page.update!(body: "[[long hair]]")
|
||||
assert_equal(1, @wiki_page.dtext_links.size)
|
||||
|
||||
Reference in New Issue
Block a user