Skip to content

Commit

Permalink
Ohm no longer has validations
Browse files Browse the repository at this point in the history
  • Loading branch information
gabebw committed Jan 13, 2015
1 parent 9c6e55c commit b14dec1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
4 changes: 0 additions & 4 deletions app/models/link.rb
Expand Up @@ -9,10 +9,6 @@ class Link < Ohm::Model
index :url
index :hash

def validate
assert_present :url
end

protected

def after_create
Expand Down
2 changes: 1 addition & 1 deletion spec/app/application_spec.rb
Expand Up @@ -2,7 +2,7 @@

describe Shawtie::Application do
context 'GET /:hash' do
let!(:link) { FactoryGirl.create(:link) }
let!(:link) { FactoryGirl.build(:link) }

before do
get "/#{link.hash}"
Expand Down
2 changes: 1 addition & 1 deletion spec/factories.rb
Expand Up @@ -4,6 +4,6 @@
url 'http://example.com'
end

initialize_with { Link.new(url: url) }
initialize_with { Link.create(url: url) }
end
end
12 changes: 2 additions & 10 deletions spec/models/link_spec.rb
@@ -1,22 +1,14 @@
require 'spec_helper'

describe Link do
context 'validations' do
it 'requires url to be present' do
link = Link.new(url: nil)
link.validate
link.errors[:url].should include :not_present
end
end

context 'callbacks' do
it 'sets hash after create' do
link = FactoryGirl.create(:link)
link = FactoryGirl.build(:link)
link.hash.should == 'b'
end

it 'persists hash after create' do
link = FactoryGirl.create(:link)
link = FactoryGirl.build(:link)
Link.find(hash: link.hash).should_not be_empty
end
end
Expand Down

0 comments on commit b14dec1

Please sign in to comment.