diff options
| author | mo khan <mo@mokhan.ca> | 2014-09-07 08:54:57 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-09-07 08:54:57 -0600 |
| commit | e072dfa874397da1567ff4397e5352dd22c39c7c (patch) | |
| tree | 79053cb8840edb43ebb86d71fc3515c1b2180119 | |
| parent | fb72df7a52b15239b99c66280ce4e9cc92855bc1 (diff) | |
use name.parameterize.
| -rw-r--r-- | app/models/creation.rb | 4 | ||||
| -rw-r--r-- | spec/models/creation_spec.rb | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/app/models/creation.rb b/app/models/creation.rb index ad4d1a00..2a6276e7 100644 --- a/app/models/creation.rb +++ b/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 diff --git a/spec/models/creation_spec.rb b/spec/models/creation_spec.rb index 43d1ac01..153ec273 100644 --- a/spec/models/creation_spec.rb +++ b/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 |
