New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't show the Notifications setting for profile only enterprises in the Users section #7307
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "admin/enterprises/form/_users.html.haml" do | ||
let(:enterprise) { build(:enterprise) } | ||
|
||
before do | ||
assign(:enterprise, enterprise) | ||
admin_user = build(:admin_user) | ||
allow(admin_user).to receive(:admin?) { true } | ||
allow(view).to receive_messages( | ||
f: enterprise_form, | ||
spree_current_user: admin_user, | ||
) | ||
end | ||
|
||
describe "notifications setting" do | ||
it "is visible when an enterprise is a distributor" do | ||
enterprise.sells = "any" | ||
|
||
render | ||
|
||
expect(rendered).to have_selector("select[name='receives_notifications']") | ||
end | ||
|
||
it "is not visible when an enterprise is a only a profile" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if they're a producer though...? Are there no emails in that case? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't be the most familiar with this but I had a look in wiki/Emails and I couldn't see any obvious emails for enterprises with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
enterprise.sells = "none" | ||
|
||
render | ||
|
||
expect(rendered).not_to have_selector("select[name='receives_notifications']") | ||
end | ||
end | ||
|
||
private | ||
|
||
def enterprise_form | ||
form_for(enterprise) { |f| @enterprise_form = f } | ||
@enterprise_form | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
unless @enterprise.producer_profile_only
would more explicitly exclude profile-only enterprises?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
unless @enterprise.producer_profile_only
sounds better and I was going to change it there but I think I spotted a bug.I don't think
producer_profile_only
ever gets set totrue
anymore, see https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/assets/javascripts/admin/enterprises/controllers/index_producer_panel_controller.js.coffee#L12 it's assigning with=
instead of comparing with==
That makes me wonder if theproducer_profile_only
column/method can be deprecated. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great catch @cillian, I'm not sure of the consequences, tbh.
Even before this PR, I'm not sure how to set the
producer_profile_only
totrue
. This should correspond to set an enterprise as a "Producer" and "Profile only" (i.e., not a Shop, and not a Hub), right?I've found this spec, https://github.com/openfoodfoundation/openfoodnetwork/blob/master/spec/controllers/admin/enterprises_controller_spec.rb#L385 :
So, if I understand this correctly, it seems to ignores this setting and as such,
enterprise.producer_profile_only
seems never to betrue
...Update: I saw #7835 only after posting the comment above 😉