This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodoListsController < ApplicationController | |
before_action :set_current_user | |
before_action :set_todo_list, only: %i[show complete_item] | |
ORDER_OPTIONS = ['created_at', 'updated_at'] | |
def index | |
sort_order = (params[:asc] == 'false') ? 'ASC' : 'DESC' | |
@lists = @user.todo_lists.order("#{sort_by_field} #{sort_order}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReceiptPrinter | |
attr_reader :output, :items | |
COST = { | |
'meat' => 5, | |
'milk' => 3, | |
'candy' => 1, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is copied to spec/ when you run 'rails generate rspec:install' | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} |