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

Another fix

parent 78dfbca6
require 'rails_helper'
describe UserCallout do
let!(:callout) { create(:user_callout) }
it_behaves_like 'Unique enum values'
let!(:callout) { create(:user_callout) }
describe 'relationships' do
it { is_expected.to belong_to(:user) }
end
......
......@@ -4,6 +4,8 @@ describe User do
include ProjectForksHelper
include TermsHelper
it_behaves_like 'Unique enum values'
describe 'modules' do
subject { described_class }
......@@ -159,8 +161,6 @@ describe User do
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
subject { build(:user) }
end
......
# frozen_string_literal: true
shared_examples 'Unique enum values' do
described_class.defined_enums.each do |name, hash|
it "has unique values in #{name}" do
duplicated = hash.group_by(&:last).select { |key, value| value.size > 1 }
described_class.defined_enums.each do |name, enum|
it "has unique values in #{name.inspect}" do
duplicated = enum.group_by(&:last).select { |key, value| value.size > 1 }
expect(duplicated).to be_empty,
"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