Skip to content

Instantly share code, notes, and snippets.

@edlvj
Created July 24, 2019 16:23
Show Gist options
  • Save edlvj/4645201c9a682adc2fbe5786b3240793 to your computer and use it in GitHub Desktop.
Save edlvj/4645201c9a682adc2fbe5786b3240793 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
# Copyright (c) 2017-2019 SwiftComply
require 'rails_helper'
RSpec.describe 'Create enforcement', type: :system do
include_context 'tenant'
let(:enforcement_type) { create(:enforcement_type, tenant: tenant) }
let(:enforcement_status) { create(:enforcement_status, tenant: tenant) }
let(:establishment) { FactoryBot.create(:establishment, tenant: tenant) }
let(:enforcement) { FactoryBot.create(:enforcement,
establishment: establishment,
enforcement_type: enforcement_type,
enforcement_status: enforcement_status) }
let(:equipment_page) { Pages::EnforcementFormPage.new }
before do
sign_in(city_user)
visit city_establishment_path(establishment)
click_button I18n.t('city.establishments.interaction_links.new_enforcement')
end
context 'with valid attributes', js: true do
let(:valid_params) do
attributes_for(:enforcement).merge({
enforcement_status_name: enforcement_status.name,
enforcement_type_name: enforcement_type.name
})
end
it 'create successfully' do
expect do
raise 'finish'
#binding.pry
equipment_page.complete_form(valid_params)
end.to(change(Enforcement, :count).by(1).and change(Activity, :count).by(1))
expect(page).to have_content I18n.t('city.enforcements.create.success')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment