mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 09:13:36 +02:00
parent
0734eb7ff3
commit
2886cb582d
4 changed files with 9 additions and 8 deletions
|
@ -8,11 +8,15 @@ module Admin
|
||||||
helper_method :durations
|
helper_method :durations
|
||||||
helper_method :statuses
|
helper_method :statuses
|
||||||
|
|
||||||
|
def self.default_status
|
||||||
|
'effective'
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = OpenStruct.new(search_params)
|
@search = OpenStruct.new(search_params)
|
||||||
|
|
||||||
unless @search.status
|
unless @search.status
|
||||||
@search.status = default_status
|
@search.status = self.class.default_status
|
||||||
end
|
end
|
||||||
|
|
||||||
prices = ::Billing::Price.all
|
prices = ::Billing::Price.all
|
||||||
|
@ -105,11 +109,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def statuses
|
def statuses
|
||||||
::Billing::Price.statuses
|
::Billing::Price.statuses.map { |status| [status.capitalize, status] }
|
||||||
end
|
|
||||||
|
|
||||||
def default_status
|
|
||||||
'effective'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<%= f.label :status, class: 'col-sm-2 control-label' %>
|
<%= f.label :status, class: 'col-sm-2 control-label' %>
|
||||||
|
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<%= f.select :status, options_for_select(statuses, search.status), { include_blank: true },
|
<%= f.select :status, options_for_select(statuses, search.status), { include_blank: t('.any') },
|
||||||
class: 'form-control' %>
|
class: 'form-control' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,5 +29,6 @@ en:
|
||||||
update_btn: Update price
|
update_btn: Update price
|
||||||
|
|
||||||
search_form:
|
search_form:
|
||||||
|
any: Any
|
||||||
search_btn: Search
|
search_btn: Search
|
||||||
reset_btn: Reset
|
reset_btn: Reset
|
||||||
|
|
|
@ -19,7 +19,7 @@ RSpec.feature 'Viewing prices in admin area', settings: false do
|
||||||
context 'when status is given' do
|
context 'when status is given' do
|
||||||
scenario 'filters by given status' do
|
scenario 'filters by given status' do
|
||||||
visit admin_prices_path
|
visit admin_prices_path
|
||||||
select 'effective', from: 'search_status'
|
select Admin::Billing::PricesController.default_status.capitalize, from: 'search_status'
|
||||||
submit_search_form
|
submit_search_form
|
||||||
|
|
||||||
expect(page).to have_css('.price', count: 1)
|
expect(page).to have_css('.price', count: 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue