mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
parent
5fdc1938af
commit
5a533e09bf
44 changed files with 1027 additions and 375 deletions
62
spec/requests/admin/billing/prices/update_spec.rb
Normal file
62
spec/requests/admin/billing/prices/update_spec.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin price update', settings: false do
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'updates zone' do
|
||||
price = create(:price)
|
||||
create(:zone, id: 2)
|
||||
|
||||
patch admin_price_path(price), price: attributes_for(:price, zone_id: '2')
|
||||
price.reload
|
||||
|
||||
expect(price.zone_id).to eq(2)
|
||||
end
|
||||
|
||||
it 'updates operation category' do
|
||||
price = create(:price, operation_category: Billing::Price.operation_categories.first)
|
||||
|
||||
patch admin_price_path(price),
|
||||
price: attributes_for(:price, operation_category: Billing::Price.operation_categories.second)
|
||||
price.reload
|
||||
|
||||
expect(price.operation_category).to eq(Billing::Price.operation_categories.second)
|
||||
end
|
||||
|
||||
it 'updates duration' do
|
||||
price = create(:price, duration: '1 year')
|
||||
|
||||
patch admin_price_path(price), price: attributes_for(:price, duration: '2 years')
|
||||
price.reload
|
||||
|
||||
expect(price.duration).to eq('2 years')
|
||||
end
|
||||
|
||||
it 'updates valid_from' do
|
||||
price = create(:price, valid_from: '2010-07-05')
|
||||
|
||||
patch admin_price_path(price), price: attributes_for(:price, valid_from: '2010-07-06')
|
||||
price.reload
|
||||
|
||||
expect(price.valid_from).to eq(Time.zone.parse('06.07.2010'))
|
||||
end
|
||||
|
||||
it 'updates valid_to' do
|
||||
price = create(:price, valid_to: '2010-07-05')
|
||||
|
||||
patch admin_price_path(price), price: attributes_for(:price, valid_to: '2010-07-06')
|
||||
price.reload
|
||||
|
||||
expect(price.valid_to).to eq(Time.zone.parse('06.07.2010'))
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
price = create(:price)
|
||||
|
||||
patch admin_price_path(price), price: attributes_for(:price)
|
||||
|
||||
expect(response).to redirect_to admin_prices_url
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue