Skip to content

Commit

Permalink
Ignore case sensitivity in validation
Browse files Browse the repository at this point in the history
Fixes MySQL error
  • Loading branch information
cpfergus1 committed May 5, 2023
1 parent 9000bcd commit f8ddf18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.prepended(base)
base.has_many :permission_sets, through: :role_permissions

base.scope :non_base_roles, -> { where.not(name: ['admin', 'user']) }
base.validates :name, uniqueness: true
base.validates_uniqueness_of :name, case_sensitive: false
base.after_save :assign_permissions
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/spree/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

it { is_expected.to have_many :role_permissions }
it { is_expected.to have_many(:permission_sets).through(:role_permissions) }
it { is_expected.to validate_uniqueness_of :name }
it { should validate_uniqueness_of(:name).ignoring_case_sensitivity }

describe "#assign_permissions" do
it 'creates new Spree::RoleConfiguration::Role' do
Expand Down

0 comments on commit f8ddf18

Please sign in to comment.