* Reworked how post versioning works, now more closely resembles the 1.18 strategy

This commit is contained in:
albert
2011-01-26 18:10:49 -05:00
parent 683d4583ac
commit f7e2344b9f
21 changed files with 292 additions and 308 deletions

View File

@@ -1,8 +1,36 @@
require 'test_helper'
class PostVersionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "The post versions controller" do
setup do
@user = Factory.create(:user)
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 = Factory.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_equals => @post.id}}
assert_response :success
assert_not_nil(assigns(:post_versions))
end
end
end
end

View File

@@ -1,8 +1,37 @@
require 'test_helper'
class PostVotesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "The post vote controller" do
setup do
@user = Factory.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@post = Factory.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}
@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}
end
end
end
end
end
end