Add name attribute to heading content blocks
This way we can simplify the code and don't have to rely on `.try` statements which are confusing and so we don't allow them in the `Rails/SafeNavigation` Rubocop rule.
This commit is contained in:
@@ -19,4 +19,18 @@ describe Budget::ContentBlock do
|
||||
heading: heading_content_block_en.heading, locale: "es")
|
||||
expect(valid_block).to be_valid
|
||||
end
|
||||
|
||||
describe "#name" do
|
||||
it "uses the heading name" do
|
||||
block = Budget::ContentBlock.new(heading: Budget::Heading.new(name: "Central"))
|
||||
|
||||
expect(block.name).to eq "Central"
|
||||
end
|
||||
|
||||
it "returns nil on new records without heading" do
|
||||
block = Budget::ContentBlock.new
|
||||
|
||||
expect(block.name).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user