mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7307 from cillian/hide-notifications-setting-for-profiles
Don't show the Notifications setting for profile only enterprises in the Users section
This commit is contained in:
@@ -14,20 +14,21 @@
|
||||
- else
|
||||
= owner_email
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
=f.label :user_ids, t('.notifications')
|
||||
- if full_permissions
|
||||
%span.required *
|
||||
%div{'ofn-with-tip' => t('.contact_tip')}
|
||||
%a= t('admin.whats_this')
|
||||
.eight.columns.omega
|
||||
- if full_permissions
|
||||
%select.select2.fullwidth{id: 'receives_notifications_dropdown', name: 'receives_notifications', ng: {model: 'receivesNotifications', init: "receivesNotifications = '#{@enterprise.contact.id}'"}}
|
||||
%option{ng: {repeat: 'user in Enterprise.users', selected: "user.id == #{@enterprise.contact.id}", hide: '!user.confirmed'}, value: '{{user.id}}'}
|
||||
{{user.email}}
|
||||
- else
|
||||
= @enterprise.contact.email
|
||||
- if @enterprise.is_distributor
|
||||
.row
|
||||
.three.columns.alpha
|
||||
=f.label :user_ids, t('.notifications')
|
||||
- if full_permissions
|
||||
%span.required *
|
||||
%div{'ofn-with-tip' => t('.contact_tip')}
|
||||
%a= t('admin.whats_this')
|
||||
.eight.columns.omega
|
||||
- if full_permissions
|
||||
%select.select2.fullwidth{id: 'receives_notifications_dropdown', name: 'receives_notifications', ng: {model: 'receivesNotifications', init: "receivesNotifications = '#{@enterprise.contact.id}'"}}
|
||||
%option{ng: {repeat: 'user in Enterprise.users', selected: "user.id == #{@enterprise.contact.id}", hide: '!user.confirmed'}, value: '{{user.id}}'}
|
||||
{{user.email}}
|
||||
- else
|
||||
= @enterprise.contact.email
|
||||
|
||||
.row
|
||||
.three.columns.alpha
|
||||
|
||||
42
spec/views/admin/enterprises/form/_users.html.haml_spec.rb
Normal file
42
spec/views/admin/enterprises/form/_users.html.haml_spec.rb
Normal file
@@ -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
|
||||
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
|
||||
Reference in New Issue
Block a user