aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/spam_address_spec.rb49
-rw-r--r--spec/models/track_thing_spec.rb9
2 files changed, 54 insertions, 4 deletions
diff --git a/spec/models/spam_address_spec.rb b/spec/models/spam_address_spec.rb
new file mode 100644
index 000000000..79a1afd11
--- /dev/null
+++ b/spec/models/spam_address_spec.rb
@@ -0,0 +1,49 @@
+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
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 1c582564b..3edf2d1ad 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -51,10 +51,11 @@ describe TrackThing, "when tracking changes" do
end
it "will make some sane descriptions of search-based tracks" do
- tests = { 'bob variety:user' => "users matching text 'bob'",
- 'bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)' => "comments or requests which are successful or unsuccessful matching text 'bob'",
- '(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)' => 'requests which are awaiting a response',
- ' (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => 'all requests or comments' }
+ tests = { ' (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => 'all requests or comments',
+ 'bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => "all requests or comments matching text 'bob'",
+ 'bob (latest_status:successful OR latest_status:partially_successful)' => "requests which are successful matching text 'bob'",
+ '(latest_status:successful OR latest_status:partially_successful)' => 'requests which are successful',
+ 'bob' => "anything matching text 'bob'" }
tests.each do |query, description|
track_thing = TrackThing.create_track_for_search_query(query)
track_thing.track_query_description.should == description