Skip to content

Commit

Permalink
Add params to article factory
Browse files Browse the repository at this point in the history
  • Loading branch information
sk8higher committed Nov 12, 2023
1 parent b46ceb3 commit d7744e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/controllers/articles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
expect do
post :create, params: { article: { name_ru: created_article.name_ru,
name_en: created_article.name_en,
name_be: created_article.name_be,
description_ru: created_article.description_ru,
description_en: created_article.description_en,
description_be: created_article.description_be,
images: [file] } }
end.to change(Article, :count).by(1)
expect(response).to redirect_to(assigns(:article))
Expand Down
5 changes: 4 additions & 1 deletion spec/factories/articles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
FactoryBot.define do
factory :article do
link_to_default_image = Rails.root.join('spec/files/images/image6.jpg')

name_ru { Faker::Lorem.characters(number: 10) }
name_en { Faker::Lorem.characters(number: 10) }
name_be { Faker::Lorem.characters(number: 10) }
description_ru { Faker::Lorem.characters(number: 30) }
description_en { Faker::Lorem.characters(number: 30) }
description_be { Faker::Lorem.characters(number: 30) }

after :build do |article|
article.images.attach(io: File.open(Rails.root.join(link_to_default_image)), filename: 'image6.jpg', content_type: 'image/jpg')
article.images.attach(io: File.open(link_to_default_image), filename: 'image6.jpg', content_type: 'image/jpg')
end
end
end

0 comments on commit d7744e5

Please sign in to comment.