aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/spam_address_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-05-15 17:01:22 +0100
committerLouise Crow <louise.crow@gmail.com>2014-05-15 17:01:22 +0100
commitbb5f95040d377d86629012347343fbf2c7dda016 (patch)
treebe696ec2615b098db34449a982fcb09a68c9c49b /spec/models/spam_address_spec.rb
parent6d215fba5cc709c43f12f86da39a643e4be5922b (diff)
parent21027d0d1197e7ac447296ab68a25159860888b2 (diff)
Merge remote-tracking branch 'origin/release/0.18'0.18
Diffstat (limited to 'spec/models/spam_address_spec.rb')
-rw-r--r--spec/models/spam_address_spec.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/spam_address_spec.rb b/spec/models/spam_address_spec.rb
new file mode 100644
index 000000000..f28440121
--- /dev/null
+++ b/spec/models/spam_address_spec.rb
@@ -0,0 +1,59 @@
+# == Schema Information
+#
+# Table name: spam_addresses
+#
+# id :integer not null, primary key
+# email :string(255) not null
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
+require 'spec_helper'
+
+describe SpamAddress do
+
+ describe :new do
+
+ it 'requres an email address' do
+ SpamAddress.new().should_not be_valid
+ SpamAddress.new(:email => 'spam@example.org').should be_valid
+ end
+
+ it 'must have a unique email address' do
+ existing = FactoryGirl.create(:spam_address)
+ SpamAddress.new(:email => existing.email).should_not be_valid
+ end
+
+ end
+
+ describe '.spam?' do
+
+ before(:each) do
+ @spam_address = FactoryGirl.create(:spam_address)
+ end
+
+ it 'is a spam address if the address is stored' do
+ SpamAddress.spam?(@spam_address.email).should be_true
+ end
+
+ it 'is not a spam address if the adress is not stored' do
+ SpamAddress.spam?('genuine-email@example.com').should be_false
+ end
+
+ describe 'when accepting an array of emails' do
+
+ it 'is spam if any of the emails are stored' do
+ emails = ['genuine-email@example.com', @spam_address.email]
+ SpamAddress.spam?(emails).should be_true
+ end
+
+ it 'is not spam if none of the emails are stored' do
+ emails = ['genuine-email@example.com', 'genuine-email@example.org']
+ SpamAddress.spam?(emails).should be_false
+ end
+
+ end
+
+ end
+
+end