Files
danbooru/test/functional/post_versions_controller_test.rb
evazion 4f543671a2 tests: move test/helpers to test/test_helpers.
The Rails convention is for test/helpers to be used for testing the view
helpers in app/helpers. We were using it to store certain utility
methods instead. Move these to test/test_helpers so that test/helpers
can be used for its intended purpose.
2018-01-14 16:11:15 -06:00

41 lines
1.0 KiB
Ruby

require 'test_helper'
class PostVersionsControllerTest < ActionController::TestCase
def setup
super
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
def teardown
super
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "The post versions controller" do
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, {}, {:user_id => @user.id}
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}}, {:user_id => @user.id}
assert_response :success
assert_not_nil(assigns(:post_versions))
end
end
end
end