Commit 328d1a93 authored by Shinya Maeda's avatar Shinya Maeda

Another fix

parent 78dfbca6
No related merge requests found
require 'rails_helper' require 'rails_helper'
describe UserCallout do describe UserCallout do
let!(:callout) { create(:user_callout) }
it_behaves_like 'Unique enum values' it_behaves_like 'Unique enum values'
let!(:callout) { create(:user_callout) }
describe 'relationships' do describe 'relationships' do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
end end
......
...@@ -4,6 +4,8 @@ describe User do ...@@ -4,6 +4,8 @@ describe User do
include ProjectForksHelper include ProjectForksHelper
include TermsHelper include TermsHelper
it_behaves_like 'Unique enum values'
describe 'modules' do describe 'modules' do
subject { described_class } subject { described_class }
...@@ -159,8 +161,6 @@ describe User do ...@@ -159,8 +161,6 @@ describe User do
it { is_expected.to validate_length_of(:bio).is_at_most(255) } it { is_expected.to validate_length_of(:bio).is_at_most(255) }
it_behaves_like 'Unique enum values'
it_behaves_like 'an object with email-formated attributes', :email do it_behaves_like 'an object with email-formated attributes', :email do
subject { build(:user) } subject { build(:user) }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
shared_examples 'Unique enum values' do shared_examples 'Unique enum values' do
described_class.defined_enums.each do |name, hash| described_class.defined_enums.each do |name, enum|
it "has unique values in #{name}" do it "has unique values in #{name.inspect}" do
duplicated = hash.group_by(&:last).select { |key, value| value.size > 1 } duplicated = enum.group_by(&:last).select { |key, value| value.size > 1 }
expect(duplicated).to be_empty, expect(duplicated).to be_empty,
"Duplicated values detected: #{duplicated.values.map(&Hash.method(:[]))}" "Duplicated values detected: #{duplicated.values.map(&Hash.method(:[]))}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment