additional functional tests, some controller fixes
This commit is contained in:
@@ -1,8 +1,59 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
context "An artists controller" do
|
||||
setup do
|
||||
CurrentUser.user = Factory.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@artist = Factory.create(:artist)
|
||||
@user = Factory.create(:user)
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "render the new page" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the edit page" do
|
||||
get :edit, {:id => @artist.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the show page" do
|
||||
get :show, {:id => @artist.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "create an artist" do
|
||||
assert_difference("Artist.count", 1) do
|
||||
post :create, {:artist => Factory.attributes_for(:artist)}, {:user_id => @user.id}
|
||||
end
|
||||
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 = Artist.last
|
||||
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")
|
||||
version = @artist.versions.first
|
||||
post :revert, {:id => @artist.id, :version_id => version.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,59 @@
|
||||
require 'test_helper'
|
||||
|
||||
class BansControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
context "A bans controller" do
|
||||
setup do
|
||||
CurrentUser.user = Factory.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@ban = Factory.create(:ban)
|
||||
@user = Factory.create(:moderator_user)
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "render the new page" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the edit page" do
|
||||
get :edit, {:id => @ban.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the show page" do
|
||||
get :show, {:id => @ban.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "create a ban" do
|
||||
assert_difference("Ban.count", 1) do
|
||||
post :create, {:ban => Factory.attributes_for(:ban)}, {:user_id => @user.id}
|
||||
end
|
||||
ban = Ban.last
|
||||
assert_redirected_to(ban_path(ban))
|
||||
end
|
||||
|
||||
should "update a ban" do
|
||||
post :update, {:id => @ban.id, :ban => {:reason => "xxx"}}, {:user_id => @user.id}
|
||||
ban = Ban.last
|
||||
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 => @user.id}
|
||||
end
|
||||
assert_redirected_to(bans_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CommentVotesControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
context "A comment votes controller" do
|
||||
setup do
|
||||
CurrentUser.user = Factory.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@comment = Factory.create(:comment)
|
||||
@user = Factory.create(:user)
|
||||
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}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CommentsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
context "A comments controller" do
|
||||
setup do
|
||||
CurrentUser.user = Factory.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@comment = Factory.create(:comment)
|
||||
@user = Factory.create(:moderator_user)
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "render the index page" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "update a comment" do
|
||||
post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id}
|
||||
assert_redirected_to comment_path(@comment)
|
||||
end
|
||||
|
||||
should "create a comment" do
|
||||
p = Factory.create(:post)
|
||||
assert_difference("Comment.count", 1) do
|
||||
post :create, {:comment => Factory.attributes_for(:comment, :post_id => p.id)}, {:user_id => @user.id}
|
||||
end
|
||||
comment = Comment.last
|
||||
assert_redirected_to post_path(comment.post)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user