Reloading stale enterprise object in test

This commit is contained in:
Rob Harrington
2015-03-14 16:17:16 +11:00
parent 20d59cf5a5
commit bdeca54377
2 changed files with 10 additions and 9 deletions

View File

@@ -360,7 +360,7 @@ class Enterprise < ActiveRecord::Base
end
def ensure_owner_is_manager
users << owner unless users(:reload).include?(owner) || owner.admin?
users << owner unless users.include?(owner) || owner.admin?
end
def enforce_ownership_limit

View File

@@ -368,17 +368,18 @@ feature %q{
expect(find("#content-header")).to have_link "New Enterprise"
end
end
context "when I have reached my enterprise ownership limit" do
it "does not display the link to create a new enterprise" do
enterprise_user.owned_enterprises.push [supplier1]
context "when I have reached my enterprise ownership limit", js: true do
it "does not display the link to create a new enterprise" do
supplier1.reload
enterprise_user.owned_enterprises.push [supplier1]
click_link "Enterprises"
click_link "Enterprises"
page.should have_content supplier1.name
page.should have_content distributor1.name
expect(find("#content-header")).to_not have_link "New Enterprise"
end
page.should have_content supplier1.name
page.should have_content distributor1.name
expect(find("#content-header")).to_not have_link "New Enterprise"
end
end