diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-12-23 15:36:11 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-04-27 16:50:29 +0100 |
commit | 681c5f0c42f5e48a0cdc1e2437675f067f0c299e (patch) | |
tree | cef53742944852ddb8fff8da3612aa8d2f38a14e /spec/models/widget_vote_spec.rb | |
parent | 16fa2c88516a9dc5f39a953022888c526e49624f (diff) |
Add some specs for widget vote validation.
Diffstat (limited to 'spec/models/widget_vote_spec.rb')
-rw-r--r-- | spec/models/widget_vote_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/models/widget_vote_spec.rb b/spec/models/widget_vote_spec.rb new file mode 100644 index 000000000..f1e30ed22 --- /dev/null +++ b/spec/models/widget_vote_spec.rb @@ -0,0 +1,37 @@ +# == Schema Information +# +# Table name: widget_votes +# +# id :integer not null, primary key +# cookie :string(255) +# info_request_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe WidgetVote do + + describe :new do + + it 'requires an info request' do + widget_vote = WidgetVote.new + widget_vote.should_not be_valid + widget_vote.errors[:info_request].should == ["can't be blank"] + end + + it 'validates the cookie length' do + widget_vote = WidgetVote.new + widget_vote.should_not be_valid + widget_vote.errors[:cookie].should == ["is the wrong length (should be 20 characters)"] + end + + it 'is valid with a cookie and info request' do + widget_vote = FactoryGirl.create(:info_request).widget_votes.build(:cookie => 'x' * 20) + widget_vote.should be_valid + end + + end + +end |