spec/factories.rb in calagator-1.1.0 vs spec/factories.rb in calagator-2.0.0.pre.0
- old
+ new
@@ -1,9 +1,11 @@
+# frozen_string_literal: true
+
require 'faker'
FactoryBot.define do
- factory :venue, class: Calagator::Venue do
+ factory :venue, class: 'Calagator::Venue' do
sequence(:title) { |n| "Venue #{n}" }
sequence(:description) { |n| "Description of Venue #{n}." }
sequence(:address) { |n| "Address #{n}" }
sequence(:street_address) { |n| "Street #{n}" }
sequence(:locality) { |n| "City #{n}" }
@@ -16,30 +18,34 @@
sequence(:telephone) { |n| "(#{n}#{n}#{n}) #{n}#{n}#{n}-#{n}#{n}#{n}#{n}" }
sequence(:url) { |n| "http://#{n}.com" }
closed { false }
wifi { true }
access_notes { 'Access permitted.' }
- after(:create) { Sunspot.commit if Calagator::Venue::SearchEngine.kind == :sunspot }
+ after(:create) do
+ Sunspot.commit if Calagator::Venue::SearchEngine.kind == :sunspot
+ end
trait :with_multiple_tags do
- after(:create) { |venue| venue.update(tag_list: 'tag1, tag2') }
+ after(:create) { |venue| venue.tag_list.add('tag1, tag2', parse: true); venue.save }
end
end
- factory :event, class: Calagator::Event do
+ factory :event, class: 'Calagator::Event' do
sequence(:title) { |n| "Event #{n}" }
sequence(:description) { |n| "Description of Event #{n}." }
start_time { Time.zone.now.beginning_of_day }
end_time { start_time + 1.hour }
- after(:create) { Sunspot.commit if Calagator::Event::SearchEngine.kind == :sunspot }
+ after(:create) do
+ Sunspot.commit if Calagator::Event::SearchEngine.kind == :sunspot
+ end
trait :with_venue do
association :venue
end
trait :with_multiple_tags do
- after(:create) { |event| event.update(tag_list: 'tag1, tag2') }
+ after(:create) { |event| event.tag_list.add('tag1, tag2', parse: true); event.save }
end
trait :with_source do
association :source
sequence(:description) do |n|
@@ -54,10 +60,10 @@
factory :duplicate_event, parent: :event do
association :duplicate_of, factory: :event
end
- factory :source, class: Calagator::Source do
+ factory :source, class: 'Calagator::Source' do
sequence(:title) { |n| "Source #{n}" }
url { 'http://example.com' }
end
end