mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add ability to manage voucher for enterprise user
Update spec accordingly
This commit is contained in:
@@ -179,6 +179,8 @@ module Spree
|
||||
can [:admin, :create], :manager_invitation
|
||||
|
||||
can [:admin, :index], :oidc_setting
|
||||
|
||||
can [:admin, :create], Voucher
|
||||
end
|
||||
|
||||
def add_product_management_abilities(user)
|
||||
|
||||
@@ -788,6 +788,10 @@ describe Spree::Ability do
|
||||
is_expected.to have_ability([:admin, :known_users, :customers], for: :search)
|
||||
is_expected.not_to have_ability([:users], for: :search)
|
||||
end
|
||||
|
||||
it "has the ability to manage vouchers" do
|
||||
is_expected.to have_ability([:admin, :create], for: Voucher)
|
||||
end
|
||||
end
|
||||
|
||||
context 'enterprise owner' do
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require 'system_helper'
|
||||
|
||||
describe '
|
||||
As an administrator
|
||||
As an entreprise user
|
||||
I want to manage vouchers
|
||||
' do
|
||||
include WebHelper
|
||||
@@ -11,9 +11,13 @@ describe '
|
||||
|
||||
let(:enterprise) { create(:supplier_enterprise, name: 'Feedme') }
|
||||
let(:voucher_code) { 'awesomevoucher' }
|
||||
let(:enterprise_user) { create(:user, enterprise_limit: 1) }
|
||||
|
||||
before do
|
||||
Flipper.enable(:vouchers)
|
||||
|
||||
enterprise_user.enterprise_roles.build(enterprise: enterprise).save
|
||||
login_as enterprise_user
|
||||
end
|
||||
|
||||
it 'lists enterprise vouchers' do
|
||||
@@ -21,7 +25,8 @@ describe '
|
||||
Voucher.create!(enterprise: enterprise, code: voucher_code)
|
||||
|
||||
# When I go to the enterprise voucher tab
|
||||
login_as_admin_and_visit edit_admin_enterprise_path(enterprise)
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
|
||||
click_link 'Vouchers'
|
||||
|
||||
# Then I see a list of vouchers
|
||||
@@ -32,7 +37,8 @@ describe '
|
||||
it 'creates a voucher' do
|
||||
# Given an enterprise
|
||||
# When I go to the enterprise voucher tab and click new
|
||||
login_as_admin_and_visit edit_admin_enterprise_path(enterprise)
|
||||
visit edit_admin_enterprise_path(enterprise)
|
||||
|
||||
click_link 'Vouchers'
|
||||
within "#vouchers_panel" do
|
||||
click_link 'Add New'
|
||||
@@ -56,7 +62,7 @@ describe '
|
||||
it 'shows an error flash message' do
|
||||
# Given an enterprise
|
||||
# When I go to the new voucher page
|
||||
login_as_admin_and_visit new_admin_enterprise_voucher_path(enterprise)
|
||||
visit new_admin_enterprise_voucher_path(enterprise)
|
||||
|
||||
# And I fill in fields with invalid data and click save
|
||||
click_button 'Save'
|
||||
|
||||
Reference in New Issue
Block a user