Adds Sluggable concern to Poll model
This commit is contained in:
@@ -5,6 +5,7 @@ class Poll < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
include Notifiable
|
||||
include Sluggable
|
||||
|
||||
translates :name, touch: true
|
||||
translates :summary, touch: true
|
||||
@@ -129,6 +130,10 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def generate_slug?
|
||||
slug.nil?
|
||||
end
|
||||
|
||||
def only_one_active
|
||||
return unless starts_at.present?
|
||||
return unless ends_at.present?
|
||||
|
||||
@@ -75,6 +75,7 @@ feature "Admin polls" do
|
||||
expect(page).to have_content "Upcoming poll"
|
||||
expect(page).to have_content I18n.l(start_date.to_date)
|
||||
expect(page).to have_content I18n.l(end_date.to_date)
|
||||
expect(Poll.last.slug).to eq "#{Poll.last.name.to_s.parameterize}"
|
||||
end
|
||||
|
||||
scenario "Edit" do
|
||||
|
||||
Reference in New Issue
Block a user