Download spec/support/ui1_test_data.rb from denise-oneill-inbox-ru/Rails-8-API-Image-Processing: direct link, hf CLI and curl.
- Browser
- Download file 865 Bytes
-
https://huggingface.co/spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/resolve/main/spec/support/ui1_test_data.rb
- Command line
-
hf download hf://spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/spec/support/ui1_test_data.rb
-
curl -L -o ui1_test_data.rb https://huggingface.co/spaces/denise-oneill-inbox-ru/Rails-8-API-Image-Processing/resolve/main/spec/support/ui1_test_data.rb
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 | |