Skip to content

Commit

Permalink
special cover image for DANDY
Browse files Browse the repository at this point in the history
  • Loading branch information
libredmm committed Aug 10, 2024
1 parent 62d71d5 commit 96ce1df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/fanza_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def subtitle
end

def cover_image_url
if normalized_id =~ /^DANDY-/ && sample_image_urls.any?
return sample_image_urls.first
end
as_struct.imageURL&.large
end

Expand Down
21 changes: 21 additions & 0 deletions spec/models/fanza_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
end
end

describe ".cover_image_url" do
context "for DANDY series" do
subject { create :fanza_item, content_id: "dandy00123" }

context "when sample image urls are present" do
it "returns first sample image url" do
subject.raw_json["sampleImageURL"] = { "sample_l": { "image": ["dummy_url"] } }
expect(subject.cover_image_url).to eq("dummy_url")
end
end

context "when no sample image urls" do
it "returns cover image url" do
subject.raw_json["imageURL"]["large"] = "dummy_url"
subject.raw_json["sampleImageURL"] = {}
expect(subject.cover_image_url).to eq("dummy_url")
end
end
end
end

describe ".as_json" do
it "includes title" do
expect(subject.as_json).to include("title")
Expand Down

0 comments on commit 96ce1df

Please sign in to comment.