forked from mislav/will_paginate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mislav#24 from codeforboston/mjz/21-return-legal-s…
…tatus Resolve mislav#21 Return Legal Status
- Loading branch information
Showing
4 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
class Listing < ApplicationRecord | ||
def illegal? | ||
case self.description | ||
when /no\s*section\s*(8|eight)/i | ||
true | ||
when /professionals\s*only/i | ||
true | ||
when /no\s*students/i | ||
true | ||
when /no\s*couples/i | ||
true | ||
else | ||
return false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Listing, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
context 'no section eight' do | ||
it 'marks it as illegal' do | ||
listing = build(:listing, description: 'No section eight') | ||
expect(listing.illegal?).to be_truthy | ||
end | ||
end | ||
context 'professionals only' do | ||
it 'marks it as illegal' do | ||
listing = build(:listing, description: 'professionals only') | ||
expect(listing.illegal?).to be_truthy | ||
end | ||
end | ||
context 'no students' do | ||
it 'marks it as illegal' do | ||
listing = build(:listing, description: 'no students') | ||
expect(listing.illegal?).to be_truthy | ||
end | ||
end | ||
context 'no couples' do | ||
it 'marks it as illegal' do | ||
listing = build(:listing, description: 'no couples') | ||
expect(listing.illegal?).to be_truthy | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.configure do |config| | ||
config.include FactoryGirl::Syntax::Methods | ||
end |