Skip to content

Commit

Permalink
Merge 5739dae into fb45212
Browse files Browse the repository at this point in the history
  • Loading branch information
groony committed Mar 28, 2016
2 parents fb45212 + 5739dae commit c4de3c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/active_admin/inputs/filters/date_range_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def to_html
end

def gt_input_name
"#{method}_gteq"
"#{method}_gteq_date"
end
alias :input_name :gt_input_name

def lt_input_name
"#{method}_lteq"
"#{method}_lteq_date"
end

def input_html_options(input_name = gt_input_name)
Expand Down
8 changes: 8 additions & 0 deletions lib/ransack_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@
{'equals'=>'eq', 'greater_than'=>'gt', 'less_than'=>'lt'}.each do |old,current|
config.add_predicate old, arel_predicate: current
end

config.add_predicate 'gteq_date',
arel_predicate: 'gteq',
formatter: ->(v) { v.beginning_of_day }

config.add_predicate 'lteq_date',
arel_predicate: 'lt',
formatter: ->(v) { v + 1.day }
end
4 changes: 2 additions & 2 deletions spec/unit/filters/filter_form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ def filter(name, options = {})
let(:body) { Capybara.string(filter :created_at) }

it "should generate a date greater than" do
expect(body).to have_selector("input.datepicker[name='q[created_at_gteq]']")
expect(body).to have_selector("input.datepicker[name='q[created_at_gteq_date]']")
end
it "should generate a seperator" do
expect(body).to have_selector("span.seperator")
end
it "should generate a date less than" do
expect(body).to have_selector("input.datepicker[name='q[created_at_lteq]']")
expect(body).to have_selector("input.datepicker[name='q[created_at_lteq_date]']")
end
end

Expand Down

0 comments on commit c4de3c2

Please sign in to comment.