pull/9882/head
ulferts 3 years ago
parent 102615df2d
commit af5d400bb2
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 6
      app/models/attribute_help_text.rb
  2. 2
      app/models/attribute_help_text/work_package.rb
  3. 4
      spec/models/attribute_help_text/work_package_spec.rb

@ -54,11 +54,11 @@ class AttributeHelpText < ApplicationRecord
scope
end
validates_presence_of :help_text
validates_uniqueness_of :attribute_name, scope: :type
validates :help_text, presence: true
validates :attribute_name, uniqueness: { scope: :type }
def attribute_caption
@caption ||= self.class.available_attributes[attribute_name]
@attribute_caption ||= self.class.available_attributes[attribute_name]
end
def attribute_scope

@ -41,7 +41,7 @@ class AttributeHelpText::WorkPackage < AttributeHelpText
attributes
end
validates_inclusion_of :attribute_name, in: ->(*) { available_attributes.keys }
validates :attribute_name, inclusion: { in: ->(*) { available_attributes.keys } }
def type_caption
I18n.t(:label_work_package)

@ -48,6 +48,7 @@ describe AttributeHelpText::WorkPackage, type: :model do
describe '.available_attributes' do
subject { described_class.available_attributes }
it 'returns an array of potential attributes' do
expect(subject).to be_a Hash
end
@ -55,6 +56,7 @@ describe AttributeHelpText::WorkPackage, type: :model do
describe '.used_attributes' do
let!(:instance) { FactoryBot.create :work_package_help_text }
subject { described_class.used_attributes instance.type }
it 'returns used attributes' do
@ -73,8 +75,6 @@ describe AttributeHelpText::WorkPackage, type: :model do
let(:permission) { [] }
let(:static_instance) { FactoryBot.create :work_package_help_text, attribute_name: 'project' }
subject { FactoryBot.build :work_package_help_text }
before do
# need to clear the cache to free the memoized
# Type.translated_work_package_form_attributes

Loading…
Cancel
Save