add specs for material release photos dropzone on public signing form
This commit is contained in:
@@ -7,6 +7,15 @@ describe Public::MaterialReleasesController do
|
|||||||
render_views
|
render_views
|
||||||
|
|
||||||
describe "#create" do
|
describe "#create" do
|
||||||
|
it "allows photos param" do
|
||||||
|
contract_template = create(:contract_template, project: project)
|
||||||
|
|
||||||
|
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, material_release: material_release_params_with_photos }
|
||||||
|
|
||||||
|
expect(response).to be_successful
|
||||||
|
expect(MaterialRelease.last.photos.attached?).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
it "logs analytics" do
|
it "logs analytics" do
|
||||||
contract_template = create(:contract_template, project: project)
|
contract_template = create(:contract_template, project: project)
|
||||||
|
|
||||||
@@ -65,6 +74,11 @@ describe Public::MaterialReleasesController do
|
|||||||
attributes_for(:material_release, :native).except(:signature).merge(signature_param)
|
attributes_for(:material_release, :native).except(:signature).merge(signature_param)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def material_release_params_with_photos
|
||||||
|
attributes_for(:material_release, :native, :with_photo).except(:signature).merge(signature_param)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def signature_param
|
def signature_param
|
||||||
file = file_fixture("signature.png")
|
file = file_fixture("signature.png")
|
||||||
data_uri = Base64Image.from_image(file).data_uri
|
data_uri = Base64Image.from_image(file).data_uri
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ FactoryBot.define do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_photo do
|
||||||
|
photos do
|
||||||
|
path = Rails.root.join("spec", "fixtures", "files", "material_photo.png")
|
||||||
|
[Rack::Test::UploadedFile.new(path, "image/png")]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
trait :non_native do
|
trait :non_native do
|
||||||
contract do
|
contract do
|
||||||
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ feature "User managing material releases" do
|
|||||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
||||||
|
|
||||||
context "when signed out" do
|
context "when signed out" do
|
||||||
scenario "creating a release", js: true do
|
scenario "creating a release without photos", js: true do
|
||||||
contract_template = create(:contract_template, project: project)
|
contract_template = create(:contract_template, project: project)
|
||||||
|
|
||||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||||
@@ -17,10 +17,27 @@ feature "User managing material releases" do
|
|||||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||||
end
|
end
|
||||||
|
|
||||||
click_button "I have read and agree to the above"
|
click_button submit_release_button
|
||||||
|
|
||||||
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "creating a release with photos", js: true do
|
||||||
|
contract_template = create(:contract_template, project: project)
|
||||||
|
|
||||||
|
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||||
|
|
||||||
|
fill_in material_name_field, with: "Pepsi Logo"
|
||||||
|
fill_in person_first_name_field, with: "Jane"
|
||||||
|
fill_in person_last_name_field, with: "Doe"
|
||||||
|
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||||
|
|
||||||
|
drop_file Rails.root.join(file_fixture("material_photo.png")), type: :dropzone
|
||||||
|
click_button submit_release_button
|
||||||
|
|
||||||
|
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
||||||
|
expect(MaterialRelease.last.photos.attached?).to eq true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when signed in" do
|
context "when signed in" do
|
||||||
@@ -224,6 +241,10 @@ feature "User managing material releases" do
|
|||||||
t "helpers.submit.material_release.create"
|
t "helpers.submit.material_release.create"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submit_release_button
|
||||||
|
t 'shared.submit_release_long'
|
||||||
|
end
|
||||||
|
|
||||||
def create_release_notice
|
def create_release_notice
|
||||||
t "material_releases.create.notice"
|
t "material_releases.create.notice"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user