Skip to content

Commit

Permalink
Show material and trim color in currently inked entries
Browse files Browse the repository at this point in the history
  • Loading branch information
ujh committed Mar 17, 2024
1 parent 526863d commit 3c6020f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/models/collected_pen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def name
model: model,
nib: nib,
color: color,
material: material,
trim_color: trim_color,
archived: archived?
)
end
Expand Down
12 changes: 10 additions & 2 deletions app/models/concerns/pen_name.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
module PenName
extend ActiveSupport::Concern

def pen_name_generator(brand:, model:, nib:, color:, archived:)
def pen_name_generator(
brand:,
model:,
nib:,
color:,
material:,
trim_color:,
archived:
)
n = "#{brand} #{model}"
n = [n, color, nib].reject { |f| f.blank? }.join(", ")
n = [n, color, material, trim_color, nib].reject { |f| f.blank? }.join(", ")
n = "#{n} (archived)" if archived
n
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/currently_inked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def pen_name
model: collected_pen.model,
nib: nib,
color: collected_pen.color,
material: collected_pen.material,
trim_color: collected_pen.trim_color,
archived: collected_pen.archived?
)
end
Expand Down
8 changes: 6 additions & 2 deletions spec/models/currently_inked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,16 @@
end

it "uses the nib from the pen" do
expect(subject.pen_name).to eq("Pilot Custom 74, orange, M")
expect(subject.pen_name).to eq(
"Pilot Custom 74, orange, plastic, gold, M"
)
end

it "uses the nib from self" do
subject.nib = "my nib"
expect(subject.pen_name).to eq("Pilot Custom 74, orange, my nib")
expect(subject.pen_name).to eq(
"Pilot Custom 74, orange, plastic, gold, my nib"
)
end
end

Expand Down

0 comments on commit 3c6020f

Please sign in to comment.