Skip to content

Commit

Permalink
Simplify replacement of AB test content
Browse files Browse the repository at this point in the history
Previously I was wrapping the content item with another presenter,
because I knew I couldn't write to the `body` property. But I've
remembered that strings are mutable by default in ruby, so I can live
without that indirection and just do `.sub!()` (which mutates the
string).
  • Loading branch information
richardTowers committed Oct 6, 2023
1 parent a06d47d commit 57e7ef7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
7 changes: 7 additions & 0 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def show
)
@requested_variant = ab_test.requested_variant(request.headers)
@requested_variant.configure_response(response)

if @requested_variant.variant? "VideoLink"
@content_item.body.sub!(
/<li>\s*in\ the\s+<a\ href="[^"]*"><abbr\ title="[^"]+">HMRC<\/abbr>\s+app<\/a>/,
'<li>in the <a href="https://www.gov.uk/guidance/download-the-hmrc-app"><abbr title="HM Revenue and Customs">HMRC</abbr> app</a> - watch a <a href="https://www.youtube.com/watch?v=LXw9ily9rTo">video about finding your UTR number in the app</a>',
)
end
@content_item = AnswerFindYourUtrPresenter.new(@content_item, @requested_variant.variant_name)
end
# /TEMPORARY
Expand Down
32 changes: 0 additions & 32 deletions app/presenters/answer_find_your_utr_presenter.rb

This file was deleted.

0 comments on commit 57e7ef7

Please sign in to comment.