Refactor prices

#475
This commit is contained in:
Artur Beljajev 2017-04-26 00:51:06 +03:00
parent 5fdc1938af
commit 5a533e09bf
44 changed files with 1027 additions and 375 deletions

View file

@ -0,0 +1,16 @@
require 'rails_helper'
RSpec.feature 'Deleting price in admin area', settings: false do
given!(:price) { create(:price) }
background do
sign_in_to_admin_area
end
scenario 'deletes price' do
visit admin_prices_url
click_link_or_button t('admin.billing.prices.price.delete_btn')
expect(page).to have_text(t('admin.billing.prices.destroy.destroyed'))
end
end

View file

@ -0,0 +1,25 @@
require 'rails_helper'
RSpec.feature 'Editing price in admin area', settings: false do
given!(:price) { create(:price) }
background do
sign_in_to_admin_area
end
scenario 'updates price' do
visit admin_prices_url
open_form
submit_form
expect(page).to have_text(t('admin.billing.prices.update.updated'))
end
def open_form
click_link_or_button t('admin.billing.prices.price.edit_btn')
end
def submit_form
click_link_or_button t('admin.billing.prices.form.update_btn')
end
end

View file

@ -0,0 +1,37 @@
require 'rails_helper'
RSpec.feature 'New price in admin area', settings: false do
given!(:zone) { create(:zone, origin: 'test') }
background do
sign_in_to_admin_area
end
scenario 'it creates new price' do
open_list
open_form
fill_form
submit_form
expect(page).to have_text(t('admin.billing.prices.create.created'))
end
def open_list
click_link_or_button t('admin.menu.prices')
end
def open_form
click_link_or_button t('admin.billing.prices.index.new_btn')
end
def fill_form
select 'test', from: 'price_zone_id'
select Billing::Price.operation_categories.first, from: 'price_operation_category'
select Billing::Price.durations.first, from: 'price_duration'
fill_in 'price_price', with: '1'
end
def submit_form
click_link_or_button t('admin.billing.prices.form.create_btn')
end
end