Skip to content

Commit

Permalink
Merge pull request #5242 from rubyforgood/sort-milage
Browse files Browse the repository at this point in the history
Sort mileage rates by effective_dates
  • Loading branch information
FireLemons authored Sep 27, 2023
2 parents a8f9ca8 + 5c2d091 commit 483a192
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/mileage_rates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MileageRatesController < ApplicationController

def index
authorize :application, :see_mileage_rate?
@mileage_rates = MileageRate.where(casa_org: current_organization)
@mileage_rates = MileageRate.where(casa_org: current_organization).order(effective_date: :asc)
end

def new
Expand Down
14 changes: 14 additions & 0 deletions spec/controllers/mileage_rates_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "rails_helper"

RSpec.describe MileageRatesController, type: :controller do
describe "#index" do
it "render the mileage rates by effective date in ascending order" do
mileage_rate1 = FactoryBot.create(:mileage_rate, effective_date: Date.new(2023, 3, 1))
mileage_rate2 = FactoryBot.create(:mileage_rate, effective_date: Date.new(2023, 1, 1))
mileage_rate3 = FactoryBot.create(:mileage_rate, effective_date: Date.new(2023, 2, 1))
mileage_rates = MileageRate.order(effective_date: :asc)
get :index
expect(mileage_rates).to eq([mileage_rate2, mileage_rate3, mileage_rate1])
end
end
end

0 comments on commit 483a192

Please sign in to comment.