* Added post voting (partial)
* Fixed jrails * Added header to comment/index * Post votes now store the score
This commit is contained in:
1
app/views/post_votes/create.js.rjs
Normal file
1
app/views/post_votes/create.js.rjs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
page["#score-for-post-#{@post.id} span"].val(@post.score)
|
||||||
29
test/unit/post_vote_test.rb
Normal file
29
test/unit/post_vote_test.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
require_relative '../test_helper'
|
||||||
|
|
||||||
|
class PostVoteTest < ActiveSupport::TestCase
|
||||||
|
setup do
|
||||||
|
user = Factory.create(:user)
|
||||||
|
CurrentUser.user = user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
|
||||||
|
@post = Factory.create(:post)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Voting for a post" do
|
||||||
|
should "interpret up as +1 score" do
|
||||||
|
vote = PostVote.create(:post_id => @post.id, :score => "up")
|
||||||
|
assert_equal(1, vote.score)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "interpret down as -1 score" do
|
||||||
|
vote = PostVote.create(:post_id => @post.id, :score => "down")
|
||||||
|
assert_equal(-1, vote.score)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not accept any other scores" do
|
||||||
|
vote = PostVote.create(:post_id => @post.id, :score => "xxx")
|
||||||
|
assert(vote.errors.any?)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
3
vendor/plugins/jrails/init.rb
vendored
Normal file
3
vendor/plugins/jrails/init.rb
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
$: << File.expand_path("..", __FILE__)
|
||||||
|
|
||||||
|
require "lib/jrails"
|
||||||
Reference in New Issue
Block a user