Skip to content

Instantly share code, notes, and snippets.

@aponsin
Created April 6, 2012 09:03
Show Gist options
  • Save aponsin/2318307 to your computer and use it in GitHub Desktop.
Save aponsin/2318307 to your computer and use it in GitHub Desktop.
describe "updating matching categories on project save", :focus do
let(:project) { Factory.build :project }
before(:each) do
@old_matching_categories = project.matching_categories
end
it "should update the matching categories after updating the category and saving the project" do
project.category = "C01"
project.save :validate => false # saving without validation because we know the project is not complete, does not matter for that test
binding.pry
project.category should eq "C01"
project.matching_categories should_not eq @old_matching_categories
project.should_receive(:build_matching_categories).once
end
it "should not update matching categories by just saving the project without changing the category" do
project.name = "factory_project_updated"
project.save :validate => false # saving without validation because we know the project is not complete, does not matter for that test
project.matching_categories should eq @old_matching_categories
project.should_not_receive(:build_matching_categories).once
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment