Skip to content

Instantly share code, notes, and snippets.

@tpendragon
Forked from joelbrewer/project_spec.rb
Last active August 29, 2015 13:56
Show Gist options
  • Save tpendragon/8959086 to your computer and use it in GitHub Desktop.
Save tpendragon/8959086 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Project do
let!(:user) { FactoryGirl.create(:user) }
let!(:plan) { FactoryGirl.create(:plan_with_subscription, user: user) }
it "has a valid factory" do
FactoryGirl.create(:project, user: user). should be_valid
end
describe "#location_state_city" do
let(:project) { FactoryGirl.build(:project, user: user, state: "TN", city: "Nashville") }
it 'returns the state and city of the project' do
project.location_state_city.should == "Nashville, TN"
end
end
describe "#ready_to_publish?" do
required_fields = %w{city state company_name email_address phone_number description category sub_category}
required_fields.each do |field|
it "returns false if the project is missing a #{field}" do
FactoryGirl.build(:project, :user => user, field.to_sym => nil).ready_to_publish?.should == false
end
end
it 'returns false if the project has not been approved' do
FactoryGirl.build(:project, user: user, status: "not_approved").ready_to_publish?.should == false
end
it 'returns true if the project is not missing requisite fields and project is approved' do
FactoryGirl.build(:project, user: user).ready_to_publish?.should == true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment