Files
openfoodnetwork/spec/controllers/admin/invoice_settings_controller_spec.rb
Maikel Linke 5b94049620 Whitelist params for several settings for Rails 5
Rails 5 is a bit stricter and Spree's Config#set method doesn't work
with a Parameters object.
2021-02-19 14:20:15 +11:00

46 lines
936 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Admin::InvoiceSettingsController, type: :controller do
describe "#update" do
let(:params) {
{
preferences: {
enable_invoices?: 0,
invoice_style2?: 1,
enable_receipt_printing?: 1,
}
}
}
before do
allow(controller).to receive(:spree_current_user) { create(:admin_user) }
end
it "disables invoices" do
expect {
post :update, params
}.to change {
Spree::Config[:enable_invoices?]
}.to(false)
end
it "changes the invoice style" do
expect {
post :update, params
}.to change {
Spree::Config[:invoice_style2?]
}.to(true)
end
it "disables receipt printing" do
expect {
post :update, params
}.to change {
Spree::Config[:enable_receipt_printing?]
}.to(true)
end
end
end