From 42ab348d543a610c6f5adebd2ed30eadac0eb5cc Mon Sep 17 00:00:00 2001 From: Mariia Potashnykova Date: Tue, 5 Sep 2023 12:54:20 +0300 Subject: [PATCH 1/2] Update posting_spec.rb --- specs/posting_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/specs/posting_spec.rb b/specs/posting_spec.rb index 7f10e8f..b0f273d 100644 --- a/specs/posting_spec.rb +++ b/specs/posting_spec.rb @@ -31,4 +31,8 @@ expect(posting.article_with_image).to eq(response) end end -end \ No newline at end of file +end + +# missing case when posting body has no figure tag +# missing case when posting body has no image tag +# would be great to have test for covering the case of multiple images in the posting From b6a0a994967546b77099c30597ff1f6e2bc4e5c7 Mon Sep 17 00:00:00 2001 From: Mariia Potashnykova Date: Tue, 5 Sep 2023 12:55:03 +0300 Subject: [PATCH 2/2] Update posting.rb --- app/models/posting.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/posting.rb b/app/models/posting.rb index a3d3985..c2329a4 100644 --- a/app/models/posting.rb +++ b/app/models/posting.rb @@ -11,6 +11,7 @@ def article_with_image return "#{figure_start}_#{figure_end}" if figure_start.nil? || figure_end.nil? image_tags = body[figure_start...figure_end + 9] + # Avoid using magic numbers. 9 should be a constant with explanatory name return 'not include