Kill trailing whitespace in ruby files
This commit is contained in:
@@ -6,27 +6,27 @@ class AdvertisementsControllerTest < ActionController::TestCase
|
||||
@ad = FactoryGirl.create(:advertisement)
|
||||
@advertiser = FactoryGirl.create(:admin_user)
|
||||
end
|
||||
|
||||
|
||||
should "get the new page" do
|
||||
get :new, {}, {:user_id => @advertiser.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the edit page" do
|
||||
get :edit, {:id => @ad.id}, {:user_id => @advertiser.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the index page" do
|
||||
get :index, {}, {:user_id => @advertiser.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the show page" do
|
||||
get :show, {:id => @ad.id}, {:user_id => @advertiser.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "create an ad" do
|
||||
assert_difference("Advertisement.count", 1) do
|
||||
post :create, {:advertisement => FactoryGirl.attributes_for(:advertisement)}, {:user_id => @advertiser.id}
|
||||
@@ -34,21 +34,21 @@ class AdvertisementsControllerTest < ActionController::TestCase
|
||||
ad = Advertisement.last
|
||||
assert_redirected_to(advertisement_path(ad))
|
||||
end
|
||||
|
||||
|
||||
should "update an ad" do
|
||||
post :update, {:id => @ad.id, :advertisement => {:width => 100}}, {:user_id => @advertiser.id}
|
||||
ad = Advertisement.last
|
||||
assert_equal(100, ad.width)
|
||||
assert_redirected_to(advertisement_path(ad))
|
||||
end
|
||||
|
||||
|
||||
should "delete an ad" do
|
||||
assert_difference("Advertisement.count", -1) do
|
||||
post :destroy, {:id => @ad.id}, {:user_id => @advertiser.id}
|
||||
end
|
||||
assert_redirected_to(advertisements_path)
|
||||
end
|
||||
|
||||
|
||||
should "block non-advertisers" do
|
||||
regular_user = FactoryGirl.create(:user)
|
||||
get :index, {}, {:user_id => regular_user.id}
|
||||
|
||||
@@ -7,17 +7,17 @@ class ArtistVersionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@artist = FactoryGirl.create(:artist)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "get the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the index page when searching for something" do
|
||||
get :index, {:search => {:name => @artist.name}}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,38 +8,38 @@ class ArtistsControllerTest < ActionController::TestCase
|
||||
@artist = FactoryGirl.create(:artist)
|
||||
@user = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "get the new page" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the edit page" do
|
||||
get :edit, {:id => @artist.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the show page" do
|
||||
get :show, {:id => @artist.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the show page for a negated tag" do
|
||||
@artist.update_attribute(:name, "-aaa")
|
||||
get :show, {:id => @artist.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "create an artist" do
|
||||
assert_difference("Artist.count", 1) do
|
||||
post :create, {:artist => FactoryGirl.attributes_for(:artist)}, {:user_id => @user.id}
|
||||
@@ -47,14 +47,14 @@ class ArtistsControllerTest < ActionController::TestCase
|
||||
artist = Artist.last
|
||||
assert_redirected_to(artist_path(artist))
|
||||
end
|
||||
|
||||
|
||||
should "update an artist" do
|
||||
post :update, {:id => @artist.id, :artist => {:name => "xxx"}}, {:user_id => @user.id}
|
||||
@artist.reload
|
||||
assert_equal("xxx", @artist.name)
|
||||
assert_redirected_to(artist_path(@artist))
|
||||
end
|
||||
|
||||
|
||||
should "revert an artist" do
|
||||
@artist.update_attributes(:name => "xyz")
|
||||
@artist.update_attributes(:name => "abc")
|
||||
|
||||
@@ -9,32 +9,32 @@ class BansControllerTest < ActionController::TestCase
|
||||
@user = FactoryGirl.create(:user)
|
||||
@ban = FactoryGirl.create(:ban, :user_id => @user.id)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "get the new page" do
|
||||
get :new, {}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the edit page" do
|
||||
get :edit, {:id => @ban.id}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the show page" do
|
||||
get :show, {:id => @ban.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "get the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "create a ban" do
|
||||
assert_difference("Ban.count", 1) do
|
||||
post :create, {:ban => {:duration => 60, :reason => "xxx", :user_id => @user.id}}, {:user_id => @mod.id}
|
||||
@@ -42,14 +42,14 @@ class BansControllerTest < ActionController::TestCase
|
||||
ban = Ban.last
|
||||
assert_redirected_to(ban_path(ban))
|
||||
end
|
||||
|
||||
|
||||
should "update a ban" do
|
||||
post :update, {:id => @ban.id, :ban => {:reason => "xxx", :duration => 60}}, {:user_id => @mod.id}
|
||||
@ban.reload
|
||||
assert_equal("xxx", @ban.reason)
|
||||
assert_redirected_to(ban_path(@ban))
|
||||
end
|
||||
|
||||
|
||||
should "destroy a ban" do
|
||||
assert_difference("Ban.count", -1) do
|
||||
post :destroy, {:id => @ban.id}, {:user_id => @mod.id}
|
||||
|
||||
@@ -8,19 +8,19 @@ class CommentVotesControllerTest < ActionController::TestCase
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "create a vote" do
|
||||
assert_difference("CommentVote.count", 1) do
|
||||
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "fail silently on errors" do
|
||||
FactoryGirl.create(:comment_vote, :comment => @comment)
|
||||
assert_difference("CommentVote.count", 0) do
|
||||
|
||||
@@ -10,7 +10,7 @@ class CommentsControllerTest < ActionController::TestCase
|
||||
@comment = FactoryGirl.create(:comment, :post => @post)
|
||||
@user = FactoryGirl.create(:moderator_user)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
@@ -21,20 +21,20 @@ class CommentsControllerTest < ActionController::TestCase
|
||||
get :index, {:group_by => "post"}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "render by comment" do
|
||||
get :index, {:group_by => "comment"}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
should "update the comment" do
|
||||
post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id}
|
||||
assert_redirected_to post_path(@comment.post)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action"do
|
||||
should "create a comment" do
|
||||
assert_difference("Comment.count", 1) do
|
||||
|
||||
@@ -9,18 +9,18 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@dmail = FactoryGirl.create(:dmail, :owner => @user)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "get the page" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with a respond_to_id" do
|
||||
should "prefill the fields" do
|
||||
get :new, {:respond_to_id => @dmail}, {:user_id => @user.id}
|
||||
@@ -28,7 +28,7 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
assert_not_nil assigns(:dmail)
|
||||
assert_equal(@dmail.from_id, assigns(:dmail).to_id)
|
||||
end
|
||||
|
||||
|
||||
context "and a forward flag" do
|
||||
should "not populate the to field" do
|
||||
get :new, {:respond_to_id => @dmail, :forward => true}, {:user_id => @user.id}
|
||||
@@ -39,7 +39,7 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
should "show dmails owned by the current user" do
|
||||
get :index, {:owner_id_equals => @dmail.owner_id, :folder => "sent"}, {:user_id => @dmail.owner_id}
|
||||
@@ -50,32 +50,32 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
assert_response :success
|
||||
assert_equal(1, assigns[:dmails].size)
|
||||
end
|
||||
|
||||
|
||||
should "not show dmails not owned by the current user" do
|
||||
get :index, {:owner_id_equals => @dmail.owner_id}, {:user_id => @unrelated_user.id}
|
||||
assert_response :success
|
||||
assert_equal(0, assigns[:dmails].size)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
should "show dmails owned by the current user" do
|
||||
get :show, {:id => @dmail.id}, {:user_id => @dmail.owner_id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "not show dmails not owned by the current user" do
|
||||
assert_raise(User::PrivilegeError) do
|
||||
get :show, {:id => @dmail.id}, {:user_id => @unrelated_user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
setup do
|
||||
@user_2 = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
should "create two messages, one for the sender and one for the recipient" do
|
||||
assert_difference("Dmail.count", 2) do
|
||||
dmail_attribs = {:to_id => @user_2.id, :title => "abc", :body => "abc"}
|
||||
@@ -84,7 +84,7 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
should "allow deletion if the dmail is owned by the current user" do
|
||||
assert_difference("Dmail.count", -1) do
|
||||
@@ -92,7 +92,7 @@ class DmailsControllerTest < ActionController::TestCase
|
||||
assert_redirected_to dmails_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "not allow deletion if the dmail is not owned by the current user" do
|
||||
assert_difference("Dmail.count", 0) do
|
||||
assert_raises(User::PrivilegeError) do
|
||||
|
||||
@@ -7,32 +7,32 @@ class FavoritesControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post.add_favorite!(@user)
|
||||
end
|
||||
|
||||
|
||||
context "with a specified tags parameter" do
|
||||
should "redirect to the posts controller" do
|
||||
get :index, {:tags => "fav:#{@user.name} abc"}, {:user_id => @user}
|
||||
assert_redirected_to(posts_path(:tags => "fav:#{@user.name} abc"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "display the current user's favorites" do
|
||||
get :index, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:favorite_set))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@@ -44,13 +44,13 @@ class FavoritesControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post.add_favorite!(@user)
|
||||
end
|
||||
|
||||
|
||||
should "remove the favorite from the current user" do
|
||||
assert_difference("Favorite.count", -1) do
|
||||
post :destroy, {:format => "js", :id => @post.id}, {:user_id => @user.id}
|
||||
|
||||
@@ -11,25 +11,25 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
@forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
||||
@forum_post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx")
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
should "list all forum posts" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search conditions" do
|
||||
should "list all matching forum posts" do
|
||||
get :index, {:search => {:body_matches => "xxx"}}
|
||||
assert_response :success
|
||||
assert_equal(1, assigns(:forum_posts).size)
|
||||
end
|
||||
|
||||
|
||||
should "list nothing for when the search matches nothing" do
|
||||
get :index, {:search => {:body_matches => "bababa"}}
|
||||
assert_response :success
|
||||
@@ -37,32 +37,32 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
should "render if the editor is the creator of the topic" do
|
||||
get :edit, {:id => @forum_post.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "render if the editor is a moderator" do
|
||||
get :edit, {:id => @forum_post.id}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "fail if the editor is not the creator of the topic and is not a moderator" do
|
||||
assert_raises(User::PrivilegeError) do
|
||||
get :edit, {:id => @forum_post.id}, {:user_id => @other_user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id, :topic_id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new forum post" do
|
||||
assert_difference("ForumPost.count", 1) do
|
||||
@@ -73,7 +73,7 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
assert_redirected_to(forum_topic_path(@forum_topic, :page => 1))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
should "destroy the posts" do
|
||||
CurrentUser.user = @mod
|
||||
@@ -83,12 +83,12 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
assert_equal(true, @forum_post.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "undelete action" do
|
||||
setup do
|
||||
@forum_post.update_attribute(:is_deleted, true)
|
||||
end
|
||||
|
||||
|
||||
should "restore the post" do
|
||||
post :undelete, {:id => @forum_post.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_post_path(@forum_post))
|
||||
|
||||
@@ -10,25 +10,25 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
@mod = FactoryGirl.create(:moderator_user)
|
||||
@forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
should "list all forum topics" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search conditions" do
|
||||
should "list all matching forum topics" do
|
||||
get :index, {:search => {:title_matches => "forum"}}
|
||||
assert_response :success
|
||||
assert_equal(1, assigns(:forum_topics).size)
|
||||
end
|
||||
|
||||
|
||||
should "list nothing for when the search matches nothing" do
|
||||
get :index, {:search => {:title_matches => "bababa"}}
|
||||
assert_response :success
|
||||
@@ -36,32 +36,32 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
should "render if the editor is the creator of the topic" do
|
||||
get :edit, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "render if the editor is a moderator" do
|
||||
get :edit, {:id => @forum_topic.id}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "fail if the editor is not the creator of the topic and is not a moderator" do
|
||||
assert_raises(User::PrivilegeError) do
|
||||
get :edit, {:id => @forum_topic.id}, {:user_id => @other_user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new forum topic and post" do
|
||||
assert_difference(["ForumPost.count", "ForumTopic.count"], 1) do
|
||||
@@ -72,12 +72,12 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
assert_redirected_to(forum_topic_path(forum_topic))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id)
|
||||
end
|
||||
|
||||
|
||||
should "destroy the topic and any associated posts" do
|
||||
post :destroy, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
@@ -85,12 +85,12 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
assert_equal(true, @forum_topic.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "undelete action" do
|
||||
setup do
|
||||
@forum_topic.update_attribute(:is_deleted, true)
|
||||
end
|
||||
|
||||
|
||||
should "restore the topic" do
|
||||
post :undelete, {:id => @forum_topic.id}, {:user_id => @user.id}
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
|
||||
@@ -7,7 +7,7 @@ class IpBansControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @admin.id}
|
||||
@@ -22,17 +22,17 @@ class IpBansControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
FactoryGirl.create(:ip_ban)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:ip_addr => "1.2.3.4"}}, {:user_id => @admin.id}
|
||||
@@ -40,12 +40,12 @@ class IpBansControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@ip_ban = FactoryGirl.create(:ip_ban)
|
||||
end
|
||||
|
||||
|
||||
should "destroy an ip ban" do
|
||||
assert_difference("IpBan.count", -1) do
|
||||
post :destroy, {:id => @ip_ban.id, :format => "js"}, {:user_id => @admin.id}
|
||||
|
||||
@@ -8,11 +8,11 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @admin.id}
|
||||
@@ -27,12 +27,12 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "promote action" do
|
||||
setup do
|
||||
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||
end
|
||||
|
||||
|
||||
should "promote the janitor trial" do
|
||||
assert_difference("JanitorTrial.count", -1) do
|
||||
post :promote, {:id => @janitor_trial.id}, {:user_id => @admin.id}
|
||||
@@ -41,12 +41,12 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
||||
assert(@user.is_janitor?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "demote action" do
|
||||
setup do
|
||||
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||
end
|
||||
|
||||
|
||||
should "demote the janitor trial" do
|
||||
assert_difference("JanitorTrial.count", -1) do
|
||||
post :demote, {:id => @janitor_trial.id}, {:user_id => @admin.id}
|
||||
@@ -55,17 +55,17 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
||||
assert(!@user.is_janitor?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
FactoryGirl.create(:janitor_trial)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:user_name => @user.name}}, {:user_id => @admin.id}
|
||||
|
||||
@@ -17,7 +17,7 @@ module Maintenance
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "render the new page" do
|
||||
get :new
|
||||
assert_response :success
|
||||
|
||||
@@ -16,18 +16,18 @@ module Maintenance
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "render the new page" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
context "given invalid parameters" do
|
||||
setup do
|
||||
post :create, {:nonce => {:email => ""}}
|
||||
end
|
||||
|
||||
|
||||
should "not create a new nonce" do
|
||||
assert_equal(0, UserPasswordResetNonce.count)
|
||||
end
|
||||
@@ -40,7 +40,7 @@ module Maintenance
|
||||
assert_equal(0, ActionMailer::Base.deliveries.size)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "given valid parameters" do
|
||||
setup do
|
||||
post :create, {:nonce => {:email => @user.email}}
|
||||
@@ -49,7 +49,7 @@ module Maintenance
|
||||
should "create a new nonce" do
|
||||
assert_equal(1, UserPasswordResetNonce.where(:email => @user.email).count)
|
||||
end
|
||||
|
||||
|
||||
should "redirect to the new page" do
|
||||
assert_redirected_to new_maintenance_user_password_reset_path
|
||||
end
|
||||
@@ -70,7 +70,7 @@ module Maintenance
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with valid parameters" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@@ -78,24 +78,24 @@ module Maintenance
|
||||
ActionMailer::Base.deliveries.clear
|
||||
get :edit, :email => @nonce.email, :key => @nonce.key
|
||||
end
|
||||
|
||||
|
||||
should "succeed" do
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
context "with invalid parameters" do
|
||||
setup do
|
||||
get :update
|
||||
end
|
||||
|
||||
|
||||
should "fail" do
|
||||
assert_redirected_to new_maintenance_user_password_reset_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "with valid parameters" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@@ -104,20 +104,20 @@ module Maintenance
|
||||
@old_password = @user.bcrypt_password_hash
|
||||
post :update, :email => @nonce.email, :key => @nonce.key
|
||||
end
|
||||
|
||||
|
||||
should "succeed" do
|
||||
assert_redirected_to new_maintenance_user_password_reset_path
|
||||
end
|
||||
|
||||
|
||||
should "send an email" do
|
||||
assert_equal(1, ActionMailer::Base.deliveries.size)
|
||||
end
|
||||
|
||||
|
||||
should "change the password" do
|
||||
@user.reload
|
||||
assert_not_equal(@old_password, @user.bcrypt_password_hash)
|
||||
end
|
||||
|
||||
|
||||
should "delete the nonce" do
|
||||
assert_equal(0, UserPasswordResetNonce.count)
|
||||
end
|
||||
|
||||
@@ -15,63 +15,63 @@ module Moderator
|
||||
setup do
|
||||
@mod_action = FactoryGirl.create(:mod_action)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
assert_equal(1, ModAction.count)
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for user feedbacks" do
|
||||
setup do
|
||||
@feedback = FactoryGirl.create(:user_feedback)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
assert_equal(1, UserFeedback.count)
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for wiki pages" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
assert_equal(1, WikiPageVersion.count)
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for tags and uploads" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
assert_equal(1, PostVersion.count)
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for notes"do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@note = FactoryGirl.create(:note, :post_id => @post.id)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
assert_equal(1, NoteVersion.count)
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for comments" do
|
||||
setup do
|
||||
@users = (0..5).map {FactoryGirl.create(:user)}
|
||||
@@ -79,32 +79,32 @@ module Moderator
|
||||
CurrentUser.scoped(@users[0], "1.2.3.4") do
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
end
|
||||
|
||||
|
||||
@users.each do |user|
|
||||
CurrentUser.scoped(user, "1.2.3.4") do
|
||||
@comment.vote!(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for artists" do
|
||||
setup do
|
||||
@artist = FactoryGirl.create(:artist)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
assert_equal(1, ArtistVersion.count)
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for flags" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@@ -116,7 +116,7 @@ module Moderator
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "for appeals" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||
|
||||
@@ -8,23 +8,23 @@ module Moderator
|
||||
CurrentUser.user = @mod
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
|
||||
|
||||
@user_1 = FactoryGirl.create(:user)
|
||||
@user_2 = FactoryGirl.create(:user, :inviter_id => @mod.id)
|
||||
end
|
||||
|
||||
|
||||
should "render the new page" do
|
||||
get :new, {:invitation => {:name => @user_1.name}}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "create a new invite" do
|
||||
post :create, {:invitation => {:user_id => @user_1.id, :level => User::Levels::CONTRIBUTOR}}, {:user_id => @mod.id}
|
||||
assert_redirected_to(moderator_invitations_path)
|
||||
@user_1.reload
|
||||
assert_equal(User::Levels::CONTRIBUTOR, @user_1.level)
|
||||
end
|
||||
|
||||
|
||||
should "list invites" do
|
||||
get :index
|
||||
assert_response :success
|
||||
|
||||
@@ -15,7 +15,7 @@ module Moderator
|
||||
get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "find by user id" do
|
||||
get :index, {:search => {:user_id => @user.id.to_s}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
@@ -25,7 +25,7 @@ module Moderator
|
||||
get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "render the search page" do
|
||||
get :search, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,10 +8,10 @@ module Moderator
|
||||
@admin = FactoryGirl.create(:admin_user)
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
|
||||
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
post :create, {:post_id => @post.id, :format => "js"}, {:user_id => @admin.id}
|
||||
|
||||
@@ -8,10 +8,10 @@ module Moderator
|
||||
@admin = FactoryGirl.create(:admin_user)
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
|
||||
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("PostDisapproval.count", 1) do
|
||||
|
||||
@@ -9,12 +9,12 @@ module Moderator
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
context "delete action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
post :delete, {:id => @post.id, :reason => "xxx", :format => "js", :commit => "Delete"}, {:user_id => @admin.id}
|
||||
@post.reload
|
||||
@@ -26,7 +26,7 @@ module Moderator
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
post :undelete, {:id => @post.id, :format => "js"}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,10 +8,10 @@ module Moderator
|
||||
@admin = FactoryGirl.create(:admin_user)
|
||||
CurrentUser.user = @admin
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
|
||||
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
should "render" do
|
||||
get :show, {}, {:user_id => @admin.id}
|
||||
|
||||
@@ -9,7 +9,7 @@ module Moderator
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
should "render the edit action" do
|
||||
get :edit, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
@@ -19,7 +19,7 @@ module Moderator
|
||||
post :update, {:tag => {:predicate => "aaa", :consequent => "bbb"}}, {:user_id => @user.id}
|
||||
assert_redirected_to edit_moderator_tag_path
|
||||
end
|
||||
|
||||
|
||||
should "fail gracefully if the update action fails" do
|
||||
post :update, {:tag => {:predicate => "", :consequent => "bbb"}}, {:user_id => @user.id}
|
||||
assert_redirected_to edit_moderator_tag_path
|
||||
|
||||
@@ -8,47 +8,47 @@ class NewsUpdatesControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@news_update = FactoryGirl.create(:news_update)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
get :index, {}, :user_id => @admin.id
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, :user_id => @admin.id
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
should "render" do
|
||||
get :edit, {:id => @news_update.id}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
should "work" do
|
||||
post :update, {:id => @news_update.id, :news_update => {:message => "zzz"}}, {:user_id => @admin.id}
|
||||
assert_redirected_to(news_updates_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "work" do
|
||||
post :create, {:news_update => {:message => "zzz"}}, {:user_id => @admin.id}
|
||||
assert_redirected_to(news_updates_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
should "work" do
|
||||
post :destroy, {:id => @news_update.id, :format => "js"}, {:user_id => @admin.id}
|
||||
|
||||
@@ -7,33 +7,33 @@ class NoteVersionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@note = FactoryGirl.create(:note)
|
||||
@user_2 = FactoryGirl.create(:user)
|
||||
|
||||
|
||||
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
||||
@note.update_attributes(:body => "1 2")
|
||||
end
|
||||
|
||||
|
||||
CurrentUser.scoped(@user, "1.2.3.4") do
|
||||
@note.update_attributes(:body => "1 2 3")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "list all versions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:note_versions))
|
||||
assert_equal(3, assigns(:note_versions).size)
|
||||
end
|
||||
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:updater_id => @user_2.id}}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,27 +8,27 @@ class NotesControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
FactoryGirl.create(:note)
|
||||
end
|
||||
|
||||
|
||||
should "list all notes" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all notes (with search)" do
|
||||
get :index, {:search => {:body_matches => "abc"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a note" do
|
||||
assert_difference("Note.count", 1) do
|
||||
@@ -36,38 +36,38 @@ class NotesControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@note = FactoryGirl.create(:note)
|
||||
end
|
||||
|
||||
|
||||
should "update a note" do
|
||||
post :update, {:id => @note.id, :note => {:body => "xyz"}}, {:user_id => @user.id}
|
||||
@note.reload
|
||||
assert_equal("xyz", @note.body)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@note = FactoryGirl.create(:note)
|
||||
end
|
||||
|
||||
|
||||
should "destroy a note" do
|
||||
post :destroy, {:id => @note.id}, {:user_id => @user.id}
|
||||
@note.reload
|
||||
assert_equal(false, @note.is_active?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "revert action" do
|
||||
setup do
|
||||
@note = FactoryGirl.create(:note, :body => "000")
|
||||
@note.update_attributes(:body => "111")
|
||||
@note.update_attributes(:body => "222")
|
||||
end
|
||||
|
||||
|
||||
should "revert to a previous version" do
|
||||
post :revert, {:id => @note.id, :version_id => @note.versions(true).first.id}
|
||||
@note.reload
|
||||
|
||||
@@ -10,18 +10,18 @@ class PoolElementsControllerTest < ActionController::TestCase
|
||||
@post = FactoryGirl.create(:post)
|
||||
@pool = FactoryGirl.create(:pool, :name => "abc")
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "add a post to a pool" do
|
||||
post :create, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id}
|
||||
@pool.reload
|
||||
assert_equal([@post.id], @pool.post_id_array)
|
||||
end
|
||||
|
||||
|
||||
should "add a post to a pool once and only once" do
|
||||
@pool.add!(@post)
|
||||
post :create, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id}
|
||||
@@ -29,18 +29,18 @@ class PoolElementsControllerTest < ActionController::TestCase
|
||||
assert_equal([@post.id], @pool.post_id_array)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@pool.add!(@post)
|
||||
end
|
||||
|
||||
|
||||
should "remove a post from a pool" do
|
||||
post :destroy, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id}
|
||||
@pool.reload
|
||||
assert_equal([], @pool.post_id_array)
|
||||
end
|
||||
|
||||
|
||||
should "do nothing if the post is not a member of the pool" do
|
||||
@pool.remove!(@post)
|
||||
post :destroy, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id}
|
||||
|
||||
@@ -7,34 +7,34 @@ class PoolVersionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
@user_2 = FactoryGirl.create(:user)
|
||||
@user_3 = FactoryGirl.create(:user)
|
||||
|
||||
|
||||
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
||||
@pool.update_attributes(:post_ids => "1 2")
|
||||
end
|
||||
|
||||
|
||||
CurrentUser.scoped(@user_3, "5.6.7.8") do
|
||||
@pool.update_attributes(:post_ids => "1 2 3 4")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "list all versions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:pool_versions))
|
||||
assert_equal(3, assigns(:pool_versions).size)
|
||||
end
|
||||
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:updater_id => @user_2.id}}
|
||||
assert_response :success
|
||||
|
||||
@@ -9,38 +9,38 @@ class PoolsControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
FactoryGirl.create(:pool, :name => "abc")
|
||||
end
|
||||
|
||||
|
||||
should "list all pools" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all pools (with search)" do
|
||||
get :index, {:search => {:name_matches => "abc"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {:id => @pool.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a pool" do
|
||||
assert_difference("Pool.count", 1) do
|
||||
@@ -48,45 +48,45 @@ class PoolsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
end
|
||||
|
||||
|
||||
should "update a pool" do
|
||||
post :update, {:id => @pool.id, :pool => {:name => "xyz"}}, {:user_id => @user.id}
|
||||
@pool.reload
|
||||
assert_equal("xyz", @pool.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
end
|
||||
|
||||
|
||||
should "destroy a pool" do
|
||||
post :destroy, {:id => @pool.id}, {:user_id => @mod.id}
|
||||
@pool.reload
|
||||
assert_equal(true, @pool.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "undelete action" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
@pool.is_deleted = true
|
||||
@pool.save
|
||||
end
|
||||
|
||||
|
||||
should "restore a pool" do
|
||||
post :undelete, {:id => @pool.id}, {:user_id => @mod.id}
|
||||
@pool.reload
|
||||
assert_equal(false, @pool.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "revert action" do
|
||||
setup do
|
||||
@post_2 = FactoryGirl.create(:post)
|
||||
@@ -95,7 +95,7 @@ class PoolsControllerTest < ActionController::TestCase
|
||||
@pool.update_attributes(:post_ids => "#{@post.id} #{@post_2.id}")
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
should "revert to a previous version" do
|
||||
assert_equal(2, PoolVersion.count)
|
||||
version = @pool.versions(true).first
|
||||
|
||||
@@ -7,30 +7,30 @@ class PostAppealsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||
@post_appeal = FactoryGirl.create(:post_appeal, :post => @post)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:post_id => @post_appeal.post_id}}, {:user_id => @user.id}
|
||||
@@ -38,12 +38,12 @@ class PostAppealsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
setup do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||
end
|
||||
|
||||
|
||||
should "create a new appeal" do
|
||||
assert_difference("PostAppeal.count", 1) do
|
||||
post :create, {:format => "js", :post_appeal => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id}
|
||||
|
||||
@@ -7,30 +7,30 @@ class PostFlagsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post_flag = FactoryGirl.create(:post_flag, :post => @post)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:post_id => @post_flag.post_id}}, {:user_id => @user.id}
|
||||
@@ -38,12 +38,12 @@ class PostFlagsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
setup do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
should "create a new flag" do
|
||||
assert_difference("PostFlag.count", 1) do
|
||||
post :create, {:format => "js", :post_flag => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id}
|
||||
|
||||
@@ -7,25 +7,25 @@ class PostVersionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post)
|
||||
@post.update_attributes(:tag_string => "1 2", :source => "xxx")
|
||||
@post.update_attributes(:tag_string => "2 3", :rating => "e")
|
||||
end
|
||||
|
||||
|
||||
should "list all versions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:post_versions))
|
||||
end
|
||||
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:post_id => @post.id}}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,12 +8,12 @@ class PostVotesControllerTest < ActionController::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "increment a post's score if the score is positive" do
|
||||
post :create, {:post_id => @post.id, :score => "up", :format => "js"}, {:user_id => @user.id}
|
||||
@@ -21,12 +21,12 @@ class PostVotesControllerTest < ActionController::TestCase
|
||||
@post.reload
|
||||
assert_equal(1, @post.score)
|
||||
end
|
||||
|
||||
|
||||
context "for a post that has already been voted on" do
|
||||
setup do
|
||||
@post.vote!("up")
|
||||
end
|
||||
|
||||
|
||||
should "fail silently on an error" do
|
||||
assert_nothing_raised do
|
||||
post :create, {:post_id => @post.id, :score => "up", :format => "js"}, {:user_id => @user.id}
|
||||
|
||||
@@ -9,18 +9,18 @@ class PostsControllerTest < ActionController::TestCase
|
||||
@post = FactoryGirl.create(:post, :uploader_id => @user.id, :tag_string => "aaaa")
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with a search" do
|
||||
should "render" do
|
||||
get :index, {:tags => "aaaa"}
|
||||
@@ -28,29 +28,29 @@ class PostsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
should "render" do
|
||||
get :show, {:id => @post.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
should "work" do
|
||||
post :update, {:id => @post.id, :post => {:tag_string => "bbb"}}, {:user_id => @user.id}
|
||||
assert_redirected_to post_path(@post)
|
||||
|
||||
|
||||
@post.reload
|
||||
assert_equal("bbb", @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "revert action" do
|
||||
setup do
|
||||
@post.update_attributes(:tag_string => "zzz")
|
||||
end
|
||||
|
||||
|
||||
should "work" do
|
||||
@version = @post.versions(true).first
|
||||
assert_equal("aaaa", @version.tags)
|
||||
|
||||
@@ -5,14 +5,14 @@ class SessionsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new session" do
|
||||
post :create, {:name => @user.name, :password => "password"}
|
||||
@@ -20,18 +20,18 @@ class SessionsControllerTest < ActionController::TestCase
|
||||
assert_equal(@user.id, session[:user_id])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
should "clear the session" do
|
||||
post :destroy, {}, {:user_id => @user.id}
|
||||
assert_redirected_to posts_path
|
||||
|
||||
@@ -10,19 +10,19 @@ class TagAliasCorrectionsControllerTest < ActionController::TestCase
|
||||
Delayed::Worker.delay_jobs = false
|
||||
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
should "render" do
|
||||
get :show, {:tag_alias_id => @tag_alias.id}, {:user => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
post :create, {:tag_alias_id => @tag_alias.id, :commit => "Fix"}, {:user => @admin.id}
|
||||
|
||||
@@ -9,19 +9,19 @@ class TagAliasRequestsControllerTest < ActionController::TestCase
|
||||
MEMCACHE.flush_all
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
|
||||
@@ -9,28 +9,28 @@ class TagAliasesControllerTest < ActionController::TestCase
|
||||
MEMCACHE.flush_all
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
end
|
||||
|
||||
|
||||
should "list all tag aliass" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all tag_aliass (with search)" do
|
||||
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a tag alias" do
|
||||
assert_difference("TagAlias.count", 1) do
|
||||
@@ -43,7 +43,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@tag_alias = FactoryGirl.create(:tag_alias)
|
||||
end
|
||||
|
||||
|
||||
should "destroy a tag_alias" do
|
||||
assert_difference("TagAlias.count", -1) do
|
||||
post :destroy, {:id => @tag_alias.id}, {:user_id => @user.id}
|
||||
|
||||
@@ -9,19 +9,19 @@ class TagImplicationRequestsControllerTest < ActionController::TestCase
|
||||
MEMCACHE.flush_all
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
|
||||
@@ -9,22 +9,22 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
||||
MEMCACHE.flush_all
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :creator => @user)
|
||||
end
|
||||
|
||||
|
||||
should "list all tag implications" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all tag_implications (with search)" do
|
||||
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||
assert_response :success
|
||||
@@ -38,12 +38,12 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@tag_implication = FactoryGirl.create(:tag_implication, :creator => @user)
|
||||
end
|
||||
|
||||
|
||||
should "destroy a tag_implication" do
|
||||
assert_difference("TagImplication.count", -1) do
|
||||
post :destroy, {:id => @tag_implication.id}, {:user_id => @user.id}
|
||||
|
||||
@@ -7,17 +7,17 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa")
|
||||
end
|
||||
|
||||
|
||||
should "list all visible tag subscriptions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
@@ -28,31 +28,31 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa")
|
||||
end
|
||||
|
||||
|
||||
should "list all visible tag subscriptions" do
|
||||
get :posts, {:id => @tag_subscription.creator_id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :edit, {:id => @tag_subscription.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new tag subscription" do
|
||||
assert_difference("TagSubscription.count", 1) do
|
||||
@@ -60,12 +60,12 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription)
|
||||
end
|
||||
|
||||
|
||||
should "destroy the posts" do
|
||||
assert_difference("TagSubscription.count", -1) do
|
||||
post :destroy, {:id => @tag_subscription.id}, {:user_id => @user.id}
|
||||
|
||||
@@ -7,33 +7,33 @@ class TagsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
@tag = FactoryGirl.create(:tag, :name => "aaa")
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :edit, {:id => @tag.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag = FactoryGirl.create(:tag, :name => "aaa")
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:name_matches => "aaa"}}
|
||||
@@ -41,23 +41,23 @@ class TagsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
setup do
|
||||
@tag = FactoryGirl.create(:tag)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {:id => @tag.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@tag = FactoryGirl.create(:tag)
|
||||
end
|
||||
|
||||
|
||||
should "update the tag" do
|
||||
post :update, {:id => @tag.id, :tag => {:category => "1"}}, {:user_id => @user.id}
|
||||
assert_redirected_to tag_path(@tag)
|
||||
|
||||
@@ -7,23 +7,23 @@ class UploadsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "for a post that has already been uploaded" do
|
||||
setup do
|
||||
@post = FactoryGirl.create(:post, :source => "aaa")
|
||||
end
|
||||
|
||||
|
||||
should "initialize the post" do
|
||||
get :new, {:url => "aaa"}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
@@ -31,17 +31,17 @@ class UploadsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@upload = FactoryGirl.create(:source_upload)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:source => @upload.source}}, {:user_id => @user.id}
|
||||
@@ -49,18 +49,18 @@ class UploadsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
@upload = FactoryGirl.create(:jpg_upload)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {:id => @upload.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new upload" do
|
||||
assert_difference("Upload.count", 1) do
|
||||
@@ -70,12 +70,12 @@ class UploadsControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@upload = FactoryGirl.create(:jpg_upload)
|
||||
end
|
||||
|
||||
|
||||
should "process an unapproval" do
|
||||
post :update, {:id => @upload.id}, {:user_id => @user.id}
|
||||
@upload.reload
|
||||
|
||||
@@ -8,40 +8,40 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @critic
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get :new, {}, {:user_id => @critic.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :edit, {:id => @user_feedback.id}, {:user_id => @critic.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :index, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:user_id => @user.id}}, {:user_id => @critic.id}
|
||||
@@ -49,7 +49,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a new feedback" do
|
||||
assert_difference("UserFeedback.count", 1) do
|
||||
@@ -59,12 +59,12 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||
end
|
||||
|
||||
|
||||
should "delete a feedback" do
|
||||
assert_difference "UserFeedback.count", -1 do
|
||||
post :destroy, {:id => @user_feedback.id}, {:user_id => @critic.id}
|
||||
|
||||
@@ -7,38 +7,38 @@ class UsersControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
FactoryGirl.create(:user, :name => "abc")
|
||||
end
|
||||
|
||||
|
||||
should "list all users" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all users (with search)" do
|
||||
get :index, {:search => {:name_matches => "abc"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {:id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a user" do
|
||||
assert_difference("User.count", 1) do
|
||||
@@ -48,23 +48,23 @@ class UsersControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :edit, {:id => @user.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
end
|
||||
|
||||
|
||||
should "update a user" do
|
||||
post :update, {:id => @user.id, :user => {:name => "xyz"}}, {:user_id => @user.id}
|
||||
@user.reload
|
||||
|
||||
@@ -7,25 +7,25 @@ class WikiPageVersionsControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
@wiki_page.update_attributes(:body => "1 2")
|
||||
@wiki_page.update_attributes(:body => "2 3")
|
||||
end
|
||||
|
||||
|
||||
should "list all versions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:wiki_page_versions))
|
||||
end
|
||||
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:wiki_page_id => @wiki_page.id}}
|
||||
assert_response :success
|
||||
|
||||
@@ -8,45 +8,45 @@ class WikiPagesControllerTest < ActionController::TestCase
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
end
|
||||
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@wiki_page_abc = FactoryGirl.create(:wiki_page, :title => "abc")
|
||||
@wiki_page_def = FactoryGirl.create(:wiki_page, :title => "def")
|
||||
end
|
||||
|
||||
|
||||
should "list all wiki_pages" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "list all wiki_pages (with search)" do
|
||||
get :index, {:search => {:title => "abc"}}
|
||||
assert_redirected_to(wiki_page_path(@wiki_page_abc))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "show action" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
end
|
||||
|
||||
|
||||
should "render" do
|
||||
get :show, {:id => @wiki_page.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
should "render for a negated tag" do
|
||||
@wiki_page.update_attribute(:title, "-aaa")
|
||||
get :show, {:id => @wiki_page.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "create action" do
|
||||
should "create a wiki_page" do
|
||||
assert_difference("WikiPage.count", 1) do
|
||||
@@ -54,38 +54,38 @@ class WikiPagesControllerTest < ActionController::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
end
|
||||
|
||||
|
||||
should "update a wiki_page" do
|
||||
post :update, {:id => @wiki_page.id, :wiki_page => {:body => "xyz"}}, {:user_id => @user.id}
|
||||
@wiki_page.reload
|
||||
assert_equal("xyz", @wiki_page.body)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
end
|
||||
|
||||
|
||||
should "destroy a wiki_page" do
|
||||
assert_difference("WikiPage.count", -1) do
|
||||
post :destroy, {:id => @wiki_page.id}, {:user_id => @mod.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "revert action" do
|
||||
setup do
|
||||
@wiki_page = FactoryGirl.create(:wiki_page, :body => "1")
|
||||
@wiki_page.update_attributes(:body => "1 2")
|
||||
@wiki_page.update_attributes(:body => "1 2 3")
|
||||
end
|
||||
|
||||
|
||||
should "revert to a previous version" do
|
||||
version = @wiki_page.versions(true).first
|
||||
assert_equal("1", version.body)
|
||||
|
||||
Reference in New Issue
Block a user