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

42 lines
914 B
Ruby
Raw Normal View History

2018-11-29 23:31:08 -05:00
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /passports' do
2018-12-02 11:44:02 -05:00
let(:passport_plain_attributes) { attributes_for :empty_passport }
2018-11-30 00:49:51 -05:00
let :passport_all_attributes do
passport_plain_attributes.merge(
2018-12-01 05:15:27 -05:00
images: [Rack::Test::UploadedFile.new(File.open(passport_image_path))],
2018-11-30 00:49:51 -05:00
)
end
let :passport_image_path do
Rails.root.join 'fixtures', 'passport_image_1.jpg'
end
2018-11-29 23:31:08 -05:00
def make_request
2018-11-30 00:49:51 -05:00
post '/passports', params: { passport: passport_all_attributes }
2018-11-29 23:31:08 -05:00
end
specify do
expect { make_request }.to change(Passport, :count).from(0).to(1)
end
context 'after request' do
before { make_request }
specify do
2018-11-30 18:10:31 -05:00
expect(response).to redirect_to Passport.last
2018-11-30 00:49:51 -05:00
end
specify do
expect(Passport.last).to have_attributes passport_plain_attributes
end
specify do
2018-12-01 05:15:27 -05:00
expect(Passport.last.images).to be_attached
2018-11-29 23:31:08 -05:00
end
end
end