denise-oneill-inbox-ru's picture
D8 staging from 92665ef4298ecff6735b080ff7901f2c19f719a7 (part 2)
38367b5 verified
Raw History Blame Contribute Delete
865 Bytes
# frozen_string_literal: true
module Ui1TestData
def create_ui1_post(locale: :en, status: "published", title: "A UI1 post", published_at: Time.current,
scheduled_at: nil, with_content: true, with_tag: true)
author = create(:user, :author)
category = Category.create!(name: "UI1 category #{SecureRandom.hex(4)}")
post = Post.new(
user: author,
category: category,
status: status,
published_at: published_at,
scheduled_at: scheduled_at
)
Mobility.with_locale(locale) { post.title = title }
post.save!
post.content_for(locale).body = "<p>#{title} body</p>" if with_content
post.save! if with_content
post.tags << Tag.create!(name: "UI1 tag #{SecureRandom.hex(4)}") if with_tag
post
end
end
RSpec.configure do |config|
config.include Ui1TestData, type: :system
end