Merge pull request #1068 from consul/sp_physical_votes
Sp physical votes
This commit is contained in:
@@ -100,7 +100,7 @@ class SpendingProposal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def total_votes
|
||||
cached_votes_up
|
||||
cached_votes_up + physical_votes
|
||||
end
|
||||
|
||||
def code
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddPhysicalVotesToSpendingProposals < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spending_proposals, :physical_votes, :integer, default: 0
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160413122359) do
|
||||
ActiveRecord::Schema.define(version: 20160415150524) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -315,6 +315,7 @@ ActiveRecord::Schema.define(version: 20160413122359) do
|
||||
t.integer "cached_votes_up", default: 0
|
||||
t.tsvector "tsv"
|
||||
t.string "responsible_name", limit: 60
|
||||
t.integer "physical_votes", default: 0
|
||||
end
|
||||
|
||||
add_index "spending_proposals", ["author_id"], name: "index_spending_proposals_on_author_id", using: :btree
|
||||
|
||||
@@ -277,4 +277,15 @@ describe SpendingProposal do
|
||||
end
|
||||
end
|
||||
|
||||
describe "total votes" do
|
||||
it "takes into account physical votes in addition to web votes" do
|
||||
sp = create(:spending_proposal)
|
||||
sp.register_vote(create(:user, :level_two), true)
|
||||
expect(sp.total_votes).to eq(1)
|
||||
sp.physical_votes = 10
|
||||
expect(sp.total_votes).to eq(11)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user