Use the file_fixture helper in tests

This way we don't have to write `"spec/fixtures/files"` every time.

Note this method isn't included in factories. We could include it like
so:

```
FactoryBot::SyntaxRunner.class_eval do
  include ActiveSupport::Testing::FileFixtures
  self.file_fixture_path = RSpec.configuration.file_fixture_path
end
```

However, I'm not sure about the possible side effects, and since we only
use attachments in a few factories, there isn't much gain in applying
the monkey-patch.
This commit is contained in:
Javi Martín
2021-09-18 17:20:52 +02:00
parent 5ff66f96cd
commit 4f232c3a25
22 changed files with 73 additions and 80 deletions

View File

@@ -26,7 +26,7 @@ describe RemoteCensusApi do
end
describe "request messages" do
let(:valid_response) { File.read("spec/fixtures/files/remote_census_api/valid.xml") }
let(:valid_response) { File.read(file_fixture("remote_census_api/valid.xml")) }
def request_with(params)
{ "request" => params }

View File

@@ -35,7 +35,7 @@ describe "active storage tasks" do
end
it "does not modify old ckeditor attachments" do
image = Ckeditor::Picture.create!(data: Rack::Test::UploadedFile.new("spec/fixtures/files/clippy.png"))
image = Ckeditor::Picture.create!(data: Rack::Test::UploadedFile.new(file_fixture("clippy.png")))
expect(image.storage_data.attachment.name).to eq "storage_data"

View File

@@ -10,10 +10,10 @@ describe DirectUpload do
end
it "is not valid for different kind of combinations with invalid atttachment content types" do
expect(build(:direct_upload, :proposal, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :proposal, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
expect(build(:direct_upload, :proposal, :documents, attachment: File.new(file_fixture("clippy.png")))).not_to be_valid
expect(build(:direct_upload, :proposal, :image, attachment: File.new(file_fixture("empty.pdf")))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :documents, attachment: File.new(file_fixture("clippy.png")))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :image, attachment: File.new(file_fixture("empty.pdf")))).not_to be_valid
end
it "is not valid without resource_type" do

View File

@@ -5,7 +5,7 @@ describe Document do
it_behaves_like "document validations", "proposal_document"
it "stores attachments with Active Storage" do
document = create(:document, attachment: File.new("spec/fixtures/files/clippy.pdf"))
document = create(:document, attachment: File.new(file_fixture("clippy.pdf")))
expect(document.attachment).to be_attached
expect(document.attachment.filename).to eq "clippy.pdf"

View File

@@ -5,7 +5,7 @@ describe Image do
it_behaves_like "image validations", "proposal_image"
it "stores attachments with Active Storage" do
image = create(:image, attachment: File.new("spec/fixtures/files/clippy.jpg"))
image = create(:image, attachment: File.new(file_fixture("clippy.jpg")))
expect(image.attachment).to be_attached
expect(image.attachment.filename).to eq "clippy.jpg"

View File

@@ -1,7 +1,7 @@
require "rails_helper"
describe LocalCensusRecords::Import do
let(:base_files_path) { %w[spec fixtures files local_census_records import] }
let(:base_files_path) { "local_census_records/import/" }
let(:import) { build(:local_census_records_import) }
describe "Validations" do
@@ -17,7 +17,7 @@ describe LocalCensusRecords::Import do
context "When file extension" do
it "is wrong it should not be valid" do
file = Rack::Test::UploadedFile.new("spec/fixtures/files/clippy.gif")
file = Rack::Test::UploadedFile.new(file_fixture("clippy.gif"))
import = build(:local_census_records_import, file: file)
expect(import).not_to be_valid
@@ -25,7 +25,7 @@ describe LocalCensusRecords::Import do
it "is csv it should be valid" do
path = base_files_path << "valid.csv"
file = Rack::Test::UploadedFile.new(Rails.root.join(*path))
file = Rack::Test::UploadedFile.new(file_fixture(path))
import = build(:local_census_records_import, file: file)
expect(import).to be_valid
@@ -35,7 +35,7 @@ describe LocalCensusRecords::Import do
context "When file headers" do
it "are all missing it should not be valid" do
path = base_files_path << "valid-without-headers.csv"
file = Rack::Test::UploadedFile.new(Rails.root.join(*path))
file = Rack::Test::UploadedFile.new(file_fixture(path))
import = build(:local_census_records_import, file: file)
expect(import).not_to be_valid
@@ -64,7 +64,7 @@ describe LocalCensusRecords::Import do
it "Add invalid local census records to invalid_records array" do
path = base_files_path << "invalid.csv"
file = Rack::Test::UploadedFile.new(Rails.root.join(*path))
file = Rack::Test::UploadedFile.new(file_fixture(path))
import.file = file
import.save!

View File

@@ -3,7 +3,7 @@ require "rails_helper"
describe SiteCustomization::Image do
it "stores images with Active Storage" do
image = create(:site_customization_image, name: "map",
image: File.new("spec/fixtures/files/custom_map.jpg"))
image: File.new(file_fixture("custom_map.jpg")))
expect(image.image).to be_attached
expect(image.image.filename).to eq "custom_map.jpg"
@@ -13,7 +13,7 @@ describe SiteCustomization::Image do
it "is valid with a 260x80 image" do
image = build(:site_customization_image,
name: "logo_header",
image: File.new("spec/fixtures/files/logo_header-260x80.png"))
image: File.new(file_fixture("logo_header-260x80.png")))
expect(image).to be_valid
end
@@ -21,7 +21,7 @@ describe SiteCustomization::Image do
it "is valid with a 223x80 image" do
image = build(:site_customization_image,
name: "logo_header",
image: File.new("spec/fixtures/files/logo_header.png"))
image: File.new(file_fixture("logo_header.png")))
expect(image).to be_valid
end
@@ -29,7 +29,7 @@ describe SiteCustomization::Image do
it "is not valid with a 400x80 image" do
image = build(:site_customization_image,
name: "logo_header",
image: File.new("spec/fixtures/files/logo_email_custom.png"))
image: File.new(file_fixture("logo_email_custom.png")))
expect(image).not_to be_valid
end

View File

@@ -7,21 +7,21 @@ shared_examples "acts as imageable" do |imageable_factory|
describe "file extension" do
it "is not valid with '.png' extension" do
image.attachment = File.new("spec/fixtures/files/clippy.png")
image.attachment = File.new(file_fixture("clippy.png"))
expect(image).not_to be_valid
expect(image.errors[:attachment].size).to eq(1)
end
it "is not valid with '.gif' extension" do
image.attachment = File.new("spec/fixtures/files/clippy.gif")
image.attachment = File.new(file_fixture("clippy.gif"))
expect(image).not_to be_valid
expect(image.errors[:attachment].size).to eq(1)
end
it "is valid with '.jpg' extension" do
image.attachment = File.new("spec/fixtures/files/clippy.jpg")
image.attachment = File.new(file_fixture("clippy.jpg"))
expect(image).to be_valid
end
@@ -33,7 +33,7 @@ shared_examples "acts as imageable" do |imageable_factory|
end
it "is not valid when image dimmensions are smaller than 475X475" do
image.attachment = File.new("spec/fixtures/files/logo_header.jpg")
image.attachment = File.new(file_fixture("logo_header.jpg"))
expect(image).not_to be_valid
end

View File

@@ -22,7 +22,7 @@ shared_examples "document validations" do |documentable_factory|
it "is valid for all accepted content types" do
acceptedcontenttypes.each do |content_type|
extension = content_type.split("/").last
document.attachment = File.new("spec/fixtures/files/empty.#{extension}")
document.attachment = File.new(file_fixture("empty.#{extension}"))
expect(document).to be_valid
end

View File

@@ -21,7 +21,7 @@ shared_examples "image validations" do |imageable_factory|
it "is valid for all accepted content types" do
acceptedcontenttypes.each do |content_type|
extension = content_type.split("/").last
image.attachment = File.new("spec/fixtures/files/clippy.#{extension}")
image.attachment = File.new(file_fixture("clippy.#{extension}"))
expect(image).to be_valid
end
@@ -30,7 +30,7 @@ shared_examples "image validations" do |imageable_factory|
it "is not valid for png and gif image content types" do
["gif", "png"].each do |content_type|
extension = content_type.split("/").last
image.attachment = File.new("spec/fixtures/files/clippy.#{extension}")
image.attachment = File.new(file_fixture("clippy.#{extension}"))
expect(image).not_to be_valid
end

View File

@@ -51,7 +51,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable.class.max_documents_allowed.times.each do
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
end
expect(page).to have_css ".max-documents-notice"
@@ -77,7 +77,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
click_link "Add new document"
within "#nested-documents" do
attach_file "Choose document", Rails.root.join("spec/fixtures/files/empty.pdf")
attach_file "Choose document", file_fixture("empty.pdf")
expect(page).to have_css ".loading-bar.complete"
end
@@ -90,7 +90,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
expect_document_has_title(0, "empty.pdf")
end
@@ -104,7 +104,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
within "#nested-documents" do
input = find("input[name$='[title]']")
fill_in input[:id], with: "My Title"
attach_file "Choose document", Rails.root.join("spec/fixtures/files/empty.pdf")
attach_file "Choose document", file_fixture("empty.pdf")
expect(page).to have_css ".loading-bar.complete"
end
@@ -116,7 +116,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
expect(page).to have_css ".loading-bar.complete"
end
@@ -125,10 +125,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(
Rails.root.join("spec/fixtures/files/logo_header.gif"),
false
)
documentable_attach_new_file(file_fixture("logo_header.gif"), false)
expect(page).to have_css ".loading-bar.errors"
end
@@ -142,7 +139,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
expect(cached_attachment_field.value).to be_empty
attach_file "Choose document", Rails.root.join("spec/fixtures/files/empty.pdf")
attach_file "Choose document", file_fixture("empty.pdf")
expect(page).to have_css(".loading-bar.complete")
expect(cached_attachment_field.value).not_to be_empty
@@ -152,10 +149,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(
Rails.root.join("spec/fixtures/files/logo_header.gif"),
false
)
documentable_attach_new_file(file_fixture("logo_header.gif"), false)
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
expect(cached_attachment_field.value).to be_empty
@@ -178,7 +172,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
click_link "Remove document"
expect(page).not_to have_css("#nested-documents .document")
@@ -201,7 +195,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
click_on submit_button
expect(page).to have_content documentable_success_notice
@@ -215,7 +209,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
click_on submit_button
documentable_redirected_to_resource_show_or_navigate_to
@@ -239,7 +233,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
send(fill_resource_method_name) if fill_resource_method_name
%w[clippy empty logo].take(documentable.class.max_documents_allowed).each do |filename|
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/#{filename}.pdf"))
documentable_attach_new_file(file_fixture("#{filename}.pdf"))
end
click_on submit_button
@@ -291,7 +285,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
do_login_for user_to_login
visit send(path, arguments)
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf"))
documentable_attach_new_file(file_fixture("empty.pdf"))
within_fieldset("Documents") { fill_in "Title", with: "Original" }
click_button submit_button

View File

@@ -38,7 +38,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
visit send(path, arguments)
click_link "Add image"
attach_file "Choose image", Rails.root.join("spec/fixtures/files/clippy.jpg")
attach_file "Choose image", file_fixture("clippy.jpg")
expect(page).to have_selector ".file-name", text: "clippy.jpg"
end
@@ -47,7 +47,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
expect_image_has_title("clippy.jpg")
end
@@ -59,7 +59,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
click_link "Add image"
input_title = find(".image input[name$='[title]']")
fill_in input_title[:id], with: "Title"
attach_file "Choose image", Rails.root.join("spec/fixtures/files/clippy.jpg")
attach_file "Choose image", file_fixture("clippy.jpg")
if has_many_images
expect(find("input[id$='_title']").value).to eq "Title"
@@ -72,7 +72,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
expect(page).to have_selector ".loading-bar.complete"
end
@@ -81,7 +81,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/logo_header.png"), false)
imageable_attach_new_file(file_fixture("logo_header.png"), false)
expect(page).to have_selector ".loading-bar.errors"
end
@@ -95,7 +95,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
expect(cached_attachment_field.value).to be_empty
attach_file "Choose image", Rails.root.join("spec/fixtures/files/clippy.jpg")
attach_file "Choose image", file_fixture("clippy.jpg")
expect(page).to have_css(".loading-bar.complete")
expect(cached_attachment_field.value).not_to be_empty
@@ -105,7 +105,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/logo_header.png"), false)
imageable_attach_new_file(file_fixture("logo_header.png"), false)
cached_attachment_field = find("input[name$='[cached_attachment]']", visible: :hidden)
@@ -133,7 +133,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
within_fieldset("Descriptive image") { fill_in "Title", with: "" }
click_on submit_button
@@ -145,7 +145,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
within "#nested-image .image" do
click_link "Remove image"
@@ -172,7 +172,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
expect(page).to have_selector ".loading-bar.complete"
@@ -186,7 +186,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
expect(page).to have_selector ".loading-bar.complete"
@@ -205,12 +205,12 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
do_login_for user
visit send(path, arguments)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
original_src = find(:fieldset, "Descriptive image").find("img")[:src]
click_link "Remove image"
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/custom_map.jpg"))
imageable_attach_new_file(file_fixture("custom_map.jpg"))
updated_src = find(:fieldset, "Descriptive image").find("img")[:src]

View File

@@ -5,15 +5,15 @@ module RemoteCensusMock
include DocumentParser
def mock_valid_remote_census_response
mock_remote_census_response(File.read("spec/fixtures/files/remote_census_api/valid.xml"))
mock_remote_census_response(File.read(file_fixture("remote_census_api/valid.xml")))
end
def mock_invalid_remote_census_response
mock_remote_census_response(File.read("spec/fixtures/files/remote_census_api/invalid.xml"))
mock_remote_census_response(File.read(file_fixture("remote_census_api/invalid.xml")))
end
def mock_invalid_signature_sheet_remote_census_response
xml = File.read("spec/fixtures/files/remote_census_api/invalid.xml")
xml = File.read(file_fixture("remote_census_api/invalid.xml"))
Signature.new.document_types.each do |document_type|
get_document_number_variants(document_type, "12345678Z").each do

View File

@@ -46,7 +46,7 @@ describe "Admin budget phases" do
scenario "shows successful notice when updating the phase with a valid image" do
visit edit_admin_budget_budget_phase_path(budget, budget.current_phase)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
click_on "Save changes"

View File

@@ -175,7 +175,7 @@ describe "Admin collaborative legislation", :admin do
fill_in "End", with: base_date + 5.days
end
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
click_button "Create process"

View File

@@ -1,7 +1,7 @@
require "rails_helper"
describe "Imports", :admin do
let(:base_files_path) { %w[spec fixtures files local_census_records import] }
let(:base_files_path) { "local_census_records/import/" }
describe "New" do
scenario "Should show import form" do
@@ -17,7 +17,7 @@ describe "Imports", :admin do
scenario "Should show success notice after successful import" do
within "form#new_local_census_records_import" do
path = base_files_path << "valid.csv"
file = File.join(Rails.root, *path)
file = file_fixture(path)
attach_file("local_census_records_import_file", file)
click_button "Save"
end
@@ -35,8 +35,7 @@ describe "Imports", :admin do
scenario "Should show alert when file is not supported" do
within "form#new_local_census_records_import" do
path = ["spec", "fixtures", "files", "clippy.jpg"]
file = File.join(Rails.root, *path)
file = file_fixture("clippy.jpg")
attach_file("local_census_records_import_file", file)
click_button "Save"
end
@@ -47,7 +46,7 @@ describe "Imports", :admin do
scenario "Should show successfully created local census records at created group" do
within "form#new_local_census_records_import" do
path = base_files_path << "valid.csv"
file = File.join(Rails.root, *path)
file = file_fixture(path)
attach_file("local_census_records_import_file", file)
click_button "Save"
end
@@ -59,7 +58,7 @@ describe "Imports", :admin do
scenario "Should show invalid local census records at errored group" do
within "form#new_local_census_records_import" do
path = base_files_path << "invalid.csv"
file = File.join(Rails.root, *path)
file = file_fixture(path)
attach_file("local_census_records_import_file", file)
click_button "Save"
end
@@ -71,7 +70,7 @@ describe "Imports", :admin do
scenario "Should show error messages inside cells at errored group" do
within "form#new_local_census_records_import" do
path = base_files_path << "invalid.csv"
file = File.join(Rails.root, *path)
file = file_fixture(path)
attach_file("local_census_records_import_file", file)
click_button "Save"
end

View File

@@ -38,7 +38,7 @@ describe "Images", :admin do
expect(page).not_to have_content("clippy.jpg")
visit new_admin_answer_image_path(answer)
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
click_button "Save image"
expect(page).to have_css("img[title='clippy.jpg']")

View File

@@ -54,7 +54,7 @@ describe "Documents", :admin do
scenario "Create" do
visit new_admin_site_customization_document_path
attach_file("document_attachment", "#{Rails.root}/spec/fixtures/files/logo.pdf")
attach_file("document_attachment", file_fixture("logo.pdf"))
click_button "Upload"
expect(page).to have_content "Document uploaded succesfully"

View File

@@ -10,7 +10,7 @@ describe "Admin custom images", :admin do
end
within("tr#image_logo_header") do
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
attach_file "site_customization_image_image", file_fixture("logo_header.png")
click_button "Update"
end
@@ -22,7 +22,7 @@ describe "Admin custom images", :admin do
visit admin_site_customization_images_path
within("tr#image_map") do
attach_file "site_customization_image_image", "spec/fixtures/files/custom_map.jpg"
attach_file "site_customization_image_image", file_fixture("custom_map.jpg")
click_button "Update"
end
@@ -37,7 +37,7 @@ describe "Admin custom images", :admin do
visit admin_site_customization_images_path
within("tr#image_map") do
attach_file "site_customization_image_image", "spec/fixtures/files/custom_map.jpg"
attach_file "site_customization_image_image", file_fixture("custom_map.jpg")
click_button "Update"
end
@@ -63,7 +63,7 @@ describe "Admin custom images", :admin do
scenario "Custom apple touch icon is replaced on front views" do
create(:site_customization_image,
name: "apple-touch-icon-200",
image: File.new("spec/fixtures/files/apple-touch-icon-custom-200.png"))
image: File.new(file_fixture("apple-touch-icon-custom-200.png")))
visit root_path
@@ -77,7 +77,7 @@ describe "Admin custom images", :admin do
visit admin_site_customization_images_path
within("tr#image_logo_email") do
attach_file "site_customization_image_image", "spec/fixtures/files/logo_email_custom.png"
attach_file "site_customization_image_image", file_fixture("logo_email_custom.png")
click_button "Update"
end
@@ -92,7 +92,7 @@ describe "Admin custom images", :admin do
visit admin_site_customization_images_path
within("tr#image_social_media_icon") do
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
attach_file "site_customization_image_image", file_fixture("logo_header.png")
click_button "Update"
end
@@ -104,7 +104,7 @@ describe "Admin custom images", :admin do
visit admin_site_customization_images_path
within("tr#image_social_media_icon") do
attach_file "site_customization_image_image", "spec/fixtures/files/social_media_icon.png"
attach_file "site_customization_image_image", file_fixture("social_media_icon.png")
click_button "Update"
end

View File

@@ -251,7 +251,7 @@ describe "Cards", :admin do
def attach_image_to_card
click_link "Add image"
attach_file "Choose image", Rails.root.join("spec/fixtures/files/clippy.jpg")
attach_file "Choose image", file_fixture("clippy.jpg")
expect(page).to have_field("widget_card_image_attributes_title", with: "clippy.jpg")
end

View File

@@ -33,7 +33,7 @@ describe "CKEditor" do
click_link "Upload"
within_frame(1) do
attach_file "Send it to the Server", Rails.root.join("spec/fixtures/files/clippy.jpg")
attach_file "Send it to the Server", file_fixture("clippy.jpg")
end
click_link "Send it to the Server"

View File

@@ -146,7 +146,7 @@ describe "Legislation Proposals" do
fill_in "Proposal title", with: "Legislation proposal with image"
fill_in "Proposal summary", with: "Including an image on a legislation proposal"
imageable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.jpg"))
imageable_attach_new_file(file_fixture("clippy.jpg"))
check "legislation_proposal_terms_of_service"
click_button "Create proposal"