Commit e072dfa8
Changed files (2)
app
models
spec
models
app/models/creation.rb
@@ -9,10 +9,10 @@ class Creation < ActiveRecord::Base
acts_as_taggable
alias_method :author, :user
- default_scope -> { order('creations.created_at desc') }
+ default_scope -> { order(created_at: :desc) }
def to_param
- "#{id}-#{name.downcase.gsub(/[^a-z0-9]+/i, '-')}"
+ "#{id}-#{name.parameterize}"
end
def primary_image
spec/models/creation_spec.rb
@@ -1,14 +1,14 @@
require 'rails_helper'
describe Creation do
- let(:sut) { Creation.new }
+ subject { Creation.new }
describe "should be able to set attributes" do
it "should save name" do
- sut.name="HELLO WORLD"
- sut.category = create(:category)
- sut.save!
- Creation.find(sut.id).name.should == "HELLO WORLD"
+ subject.name="HELLO WORLD"
+ subject.category = create(:category)
+ subject.save!
+ Creation.find(subject.id).name.should == "HELLO WORLD"
end
end