File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def __create_jsonb_typed_scopes(jsonb_attribute, fields_map)
7474 ___create_jsonb_boolean_scopes ( field )
7575 when :integer , :float , :decimal , :big_integer
7676 ___create_jsonb_numeric_scopes ( field , jsonb_attribute , type )
77- when :date_time , :date , :time
77+ when :date_time , :date
7878 ___create_jsonb_date_time_scopes ( field , jsonb_attribute , type )
7979 when /array/
8080 ___create_jsonb_array_scopes ( field )
Original file line number Diff line number Diff line change 10431043 end
10441044
10451045 context "date" do
1046+ let ( :todays_date ) { right_now . to_date }
1047+ let ( :a_day_ago ) { todays_date - 1 . day }
1048+ let ( :a_day_from_now ) { todays_date + 1 . day }
1049+ let ( :fifty_days_from_now ) { todays_date + 50 . days }
1050+ let ( :fifty_days_ago ) { todays_date - 50 . days }
1051+ let! ( :largest_product ) { Product . create! ( approved_on : fifty_days_from_now ) }
1052+ let! ( :middle_product ) { matching_product }
1053+ let! ( :smallest_product ) { Product . create! ( approved_on : fifty_days_ago ) }
1054+
10461055 describe "#<field>_before" do
1047- it "is products before the given date"
1056+ it "is products before the given date" do
1057+ expect ( Product . approved_on_before ( a_day_ago ) ) . to eq ( [ smallest_product ] )
1058+ expect ( Product . approved_on_before ( a_day_from_now ) ) . to match_array ( [ smallest_product , middle_product ] )
1059+ end
1060+
1061+ it "supports json strings" do
1062+ expect ( Product . approved_on_before ( a_day_ago . to_json ) ) . to eq ( [ smallest_product ] )
1063+ end
10481064 end
10491065
10501066 describe "#<field>_after" do
1051- it "is products after the given date"
1067+ it "is products after the given date" do
1068+ expect ( Product . approved_on_after ( a_day_from_now ) ) . to eq ( [ largest_product ] )
1069+ expect ( Product . approved_on_after ( a_day_ago ) ) . to match_array ( [ largest_product , middle_product ] )
1070+ end
1071+
1072+ it "supports json strings" do
1073+ expect ( Product . approved_on_after ( a_day_from_now . to_json ) ) . to eq ( [ largest_product ] )
1074+ end
10521075 end
10531076 end
10541077
You can’t perform that action at this time.
0 commit comments