From 9530fd939d10477381abc8b2ea635f76da53159d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 27 Apr 2017 16:51:47 +0300 Subject: [PATCH] Fix admin price UI #475 --- app/views/admin/billing/prices/_price.html.erb | 9 +-------- app/views/admin/billing/prices/edit.html.erb | 13 ++++++++++++- app/views/admin/billing/prices/index.html.erb | 1 - config/locales/admin/billing/prices.en.yml | 7 ++----- spec/features/admin/billing/prices/delete_spec.rb | 9 ++++++++- spec/features/admin/billing/prices/edit_spec.rb | 4 +++- spec/features/admin/billing/prices/new_spec.rb | 2 ++ 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/views/admin/billing/prices/_price.html.erb b/app/views/admin/billing/prices/_price.html.erb index df5de4391..f2cf2027e 100644 --- a/app/views/admin/billing/prices/_price.html.erb +++ b/app/views/admin/billing/prices/_price.html.erb @@ -1,15 +1,8 @@ - <%= price.zone_name %> + <%= link_to price.zone_name, edit_admin_price_path(price), id: 'admin-edit-price-btn' %> <%= price.duration.sub('mons', 'months') %> <%= price.operation_category %> <%= number_to_currency price.price %> <%= l price.valid_from, format: :date %> <%= l price.valid_to, format: :date %> - - <%= link_to t('.edit_btn'), edit_admin_price_path(price), class: 'btn btn-xs btn-primary' %> - <%= link_to(t('.delete_btn'), admin_price_path(price), - method: :delete, - data: { confirm: t('.delete_btn_confirm') }, - class: 'btn btn-xs btn-danger') %> - diff --git a/app/views/admin/billing/prices/edit.html.erb b/app/views/admin/billing/prices/edit.html.erb index 61cc348e2..75d82814f 100644 --- a/app/views/admin/billing/prices/edit.html.erb +++ b/app/views/admin/billing/prices/edit.html.erb @@ -3,7 +3,18 @@ <% if @price.persisted? && @price.errors.none? %> diff --git a/app/views/admin/billing/prices/index.html.erb b/app/views/admin/billing/prices/index.html.erb index ef6da0ed2..c675b8bde 100644 --- a/app/views/admin/billing/prices/index.html.erb +++ b/app/views/admin/billing/prices/index.html.erb @@ -20,7 +20,6 @@ <%= sort_link(@q, 'price', t(:price)) %> <%= sort_link(@q, 'valid_from', t(:valid_from)) %> <%= sort_link(@q, 'valid_to', t(:valid_to)) %> - diff --git a/config/locales/admin/billing/prices.en.yml b/config/locales/admin/billing/prices.en.yml index e673cf7d9..277b708da 100644 --- a/config/locales/admin/billing/prices.en.yml +++ b/config/locales/admin/billing/prices.en.yml @@ -15,6 +15,8 @@ en: edit: title: Edit price + delete_btn: Delete + delete_btn_confirm: Are you sure you want to delete price? update: updated: Price has been updated @@ -25,8 +27,3 @@ en: form: create_btn: Create price update_btn: Update price - - price: - edit_btn: Edit - delete_btn: Delete - delete_btn_confirm: Are you sure you want to delete price? diff --git a/spec/features/admin/billing/prices/delete_spec.rb b/spec/features/admin/billing/prices/delete_spec.rb index 15f46615d..37c8f4003 100644 --- a/spec/features/admin/billing/prices/delete_spec.rb +++ b/spec/features/admin/billing/prices/delete_spec.rb @@ -9,8 +9,15 @@ RSpec.feature 'Deleting price in admin area', settings: false do scenario 'deletes price' do visit admin_prices_url - click_link_or_button t('admin.billing.prices.price.delete_btn') + open_form + click_link_or_button t('admin.billing.prices.edit.delete_btn') expect(page).to have_text(t('admin.billing.prices.destroy.destroyed')) end + + private + + def open_form + click_link_or_button 'admin-edit-price-btn' + end end diff --git a/spec/features/admin/billing/prices/edit_spec.rb b/spec/features/admin/billing/prices/edit_spec.rb index d1d04a21e..6c567b5ca 100644 --- a/spec/features/admin/billing/prices/edit_spec.rb +++ b/spec/features/admin/billing/prices/edit_spec.rb @@ -15,8 +15,10 @@ RSpec.feature 'Editing price in admin area', settings: false do expect(page).to have_text(t('admin.billing.prices.update.updated')) end + private + def open_form - click_link_or_button t('admin.billing.prices.price.edit_btn') + click_link_or_button 'admin-edit-price-btn' end def submit_form diff --git a/spec/features/admin/billing/prices/new_spec.rb b/spec/features/admin/billing/prices/new_spec.rb index 27c56ffb6..ddbbac57b 100644 --- a/spec/features/admin/billing/prices/new_spec.rb +++ b/spec/features/admin/billing/prices/new_spec.rb @@ -16,6 +16,8 @@ RSpec.feature 'New price in admin area', settings: false do expect(page).to have_text(t('admin.billing.prices.create.created')) end + private + def open_list click_link_or_button t('admin.menu.prices') end