Skip to content

Commit

Permalink
added notice test: #[NOTICE_TYPES]_notice?, #[Response::STATUSES]_res…
Browse files Browse the repository at this point in the history
…ponses
  • Loading branch information
angdev committed Oct 30, 2014
1 parent 03bf7a4 commit fae8eb4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/unit/models/notice_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
require "rails_helper"

RSpec.describe Notice, :type => :model do
describe "#[NOTICE_TYPES]_notice?" do
it "should return whether notice is given type" do
given_type = Notice::NOTICE_TYPES.first
notice = FactoryGirl.create(:notice, notice_type: given_type)

expect(notice.send("#{given_type}_notice?")).to eq(true)
Notice::NOTICE_TYPES[1..-1].each do |type|
expect(notice.send("#{type}_notice?")).to eq(false)
end
end
end

describe "#[Response::STATUSES]_responses" do
it "should return responses that is given status" do
user = FactoryGirl.create(:user)
notice = FactoryGirl.create(:notice)

given_status = Response::STATUSES.first
expect(notice.send("#{given_status}_responses").empty?).to eq(true)

response = Response.create!(user: user, notice: notice, status: given_status)
expect(notice.send("#{given_status}_responses")).to match_array([response])

Response::STATUSES[1..-1].each do |status|
expect(notice.send("#{status}_responses").empty?).to eq(true)
end
end
end

describe "#save with make_redirectable_url!" do
it "should prepend protocol if not exist" do
notice = FactoryGirl.create(:notice, link: "www.google.com", shortenURL: "www.google.com")
Expand Down

0 comments on commit fae8eb4

Please sign in to comment.