diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 6725620526..462910aa0d 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -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 diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 0bd9b8dfb5..0cd6f08451 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -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