fix tests
This commit is contained in:
@@ -12,6 +12,6 @@ class FavoritesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
Post.find(params[:post_id]).remove_favorite!(CurrentUser.user)
|
Post.find(params[:id]).remove_favorite!(CurrentUser.user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
|
setup do
|
||||||
|
@post = Factory.create(:post)
|
||||||
|
@post.add_favorite!(@user)
|
||||||
|
end
|
||||||
|
|
||||||
context "with a specified tags parameter" do
|
context "with a specified tags parameter" do
|
||||||
should "redirect to the posts controller" do
|
should "redirect to the posts controller" do
|
||||||
get :index, {:tags => "abc"}, {:user_id => @user}
|
get :index, {:tags => "abc"}, {:user_id => @user}
|
||||||
@@ -24,7 +29,7 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
should "display the current user's favorites" do
|
should "display the current user's favorites" do
|
||||||
get :index, {}, {:user_id => @user.id}
|
get :index, {}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_not_nil(assigns(:post_set))
|
assert_not_nil(assigns(:favorite_set))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -34,8 +39,8 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "create a favorite for the current user" do
|
should "create a favorite for the current user" do
|
||||||
assert_difference("Favorite.count(#{@user.id})", 1) do
|
assert_difference("Favorite.count", 1) do
|
||||||
post :create, {:format => "js", :id => @post.id}, {:user_id => @user.id}
|
post :create, {:format => "js", :post_id => @post.id}, {:user_id => @user.id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -43,14 +48,11 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = Factory.create(:post)
|
||||||
Favorite.create(
|
@post.add_favorite!(@user)
|
||||||
:user_id => @user.id,
|
|
||||||
:post_id => @post.id
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "remove the favorite from the current user" do
|
should "remove the favorite from the current user" do
|
||||||
assert_difference("Favorite.count(#{@user.id})", -1) do
|
assert_difference("Favorite.count", -1) do
|
||||||
post :destroy, {:format => "js", :id => @post.id}, {:user_id => @user.id}
|
post :destroy, {:format => "js", :id => @post.id}, {:user_id => @user.id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ class NotesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a note" do
|
should "destroy a note" do
|
||||||
assert_difference("Note.count", -1) do
|
post :destroy, {:id => @note.id}, {:user_id => @user.id}
|
||||||
post :destroy, {:id => @note.id}, {:user_id => @user.id}
|
@note.reload
|
||||||
end
|
assert_equal(false, @note.is_active?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user