1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/requests/passports/create_spec.rb

41 lines
922 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /passports' do
let(:passport_plain_attributes) { attributes_for :passport_without_image }
let :passport_all_attributes do
passport_plain_attributes.merge(
images: [Rack::Test::UploadedFile.new(File.open(passport_image_path))],
)
end
let :passport_image_path do
Rails.root.join 'fixtures', 'passport_image_1.jpg'
end
def make_request
post '/passports', params: { passport: passport_all_attributes }
end
specify do
expect { make_request }.to change(Passport, :count).from(0).to(1)
end
context 'after request' do
before { make_request }
specify do
expect(response).to redirect_to Passport.last
end
specify do
expect(Passport.last).to have_attributes passport_plain_attributes
end
specify do
expect(Passport.last.images).to be_attached
end
end
end