mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
parent
5fdc1938af
commit
5a533e09bf
44 changed files with 1027 additions and 375 deletions
46
spec/requests/admin/billing/prices/create_spec.rb
Normal file
46
spec/requests/admin/billing/prices/create_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin price create', settings: false do
|
||||
let!(:zone) { create(:zone, id: 1, origin: 'test') }
|
||||
subject(:price) { Billing::Price.first }
|
||||
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'creates new price' do
|
||||
expect { post admin_prices_path, price: attributes_for(:price, zone_id: '1') }
|
||||
.to change { Billing::Price.count }.from(0).to(1)
|
||||
end
|
||||
|
||||
it 'saves zone' do
|
||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1')
|
||||
expect(price.zone_id).to eq(1)
|
||||
end
|
||||
|
||||
it 'saves operation category' do
|
||||
post admin_prices_path, price:
|
||||
attributes_for(:price, zone_id: '1', operation_category: Billing::Price.operation_categories.first)
|
||||
expect(price.operation_category).to eq(Billing::Price.operation_categories.first)
|
||||
end
|
||||
|
||||
it 'saves duration' do
|
||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', duration: '1 year')
|
||||
expect(price.duration).to eq('1 year')
|
||||
end
|
||||
|
||||
it 'saves valid_from' do
|
||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', valid_from: '2010-07-06')
|
||||
expect(price.valid_from).to eq(Time.zone.parse('06.07.2010'))
|
||||
end
|
||||
|
||||
it 'saves valid_to' do
|
||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', valid_to: '2010-07-06')
|
||||
expect(price.valid_to).to eq(Time.zone.parse('06.07.2010'))
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1')
|
||||
expect(response).to redirect_to admin_prices_url
|
||||
end
|
||||
end
|
18
spec/requests/admin/billing/prices/destroy_spec.rb
Normal file
18
spec/requests/admin/billing/prices/destroy_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'admin price destroy', settings: false do
|
||||
let!(:price) { create(:price) }
|
||||
|
||||
before :example do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'deletes price' do
|
||||
expect { delete admin_price_path(price) }.to change { Billing::Price.count }.from(1).to(0)
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
delete admin_price_path(price)
|
||||
expect(response).to redirect_to admin_prices_url
|
||||
end
|
||||
end
|
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