Adds Sluggable concern to Poll model

This commit is contained in:
María Checa
2018-07-11 15:46:10 +02:00
committed by Javi Martín
parent 65fd88ef32
commit 0c6e7e7580
2 changed files with 6 additions and 0 deletions

View File

@@ -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?

View File

@@ -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