adds published to polls
This commit is contained in:
@@ -13,6 +13,7 @@ class Poll < ActiveRecord::Base
|
||||
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) }
|
||||
scope :incoming, -> { where('? < starts_at', Time.current) }
|
||||
scope :expired, -> { where('ends_at < ?', Time.current) }
|
||||
scope :published, -> { where('published = ?', true) }
|
||||
|
||||
scope :sort_for_list, -> { order(:starts_at) }
|
||||
|
||||
|
||||
5
db/migrate/20170102170125_add_published_to_polls.rb
Normal file
5
db/migrate/20170102170125_add_published_to_polls.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddPublishedToPolls < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :polls, :published, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170102114446) do
|
||||
ActiveRecord::Schema.define(version: 20170102170125) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -360,6 +360,7 @@ ActiveRecord::Schema.define(version: 20170102114446) do
|
||||
t.string "name"
|
||||
t.datetime "starts_at"
|
||||
t.datetime "ends_at"
|
||||
t.boolean "published", default: false
|
||||
end
|
||||
|
||||
create_table "proposal_notifications", force: :cascade do |t|
|
||||
|
||||
@@ -282,6 +282,10 @@ FactoryGirl.define do
|
||||
starts_at { 1.month.ago }
|
||||
ends_at { 15.days.ago }
|
||||
end
|
||||
|
||||
trait :published do
|
||||
published true
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_question, class: 'Poll::Question' do
|
||||
|
||||
@@ -55,6 +55,13 @@ describe :poll do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#published?" do
|
||||
it "returns true only when published is true" do
|
||||
expect(create(:poll)).to_not be_published
|
||||
expect(create(:poll, :published)).to be_published
|
||||
end
|
||||
end
|
||||
|
||||
describe "#document_has_voted?" do
|
||||
it "returns true if Poll::Voter with document exists" do
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
Reference in New Issue
Block a user