From f98ba8520c4e469785b0fc564aa96705f1897c90 Mon Sep 17 00:00:00 2001 From: stephanie-warmenhoven Date: Thu, 23 Apr 2020 18:33:11 -0700 Subject: [PATCH] [#1713] Created resources_url_tags moment helper method --- app/controllers/moments_controller.rb | 12 ++++++------ app/helpers/moments_helper.rb | 8 ++++++++ app/views/moments/show.html.erb | 2 +- spec/services/resource_recommendations_spec.rb | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/moments_controller.rb b/app/controllers/moments_controller.rb index b612f37a3f..97aa1f1a67 100644 --- a/app/controllers/moments_controller.rb +++ b/app/controllers/moments_controller.rb @@ -26,12 +26,12 @@ def index def show show_with_comments(@moment) @resources = ResourceRecommendations.new(@moment).call - @matched_tags = ResourceRecommendations.new(@moment).matched_tags - @moment_keywords = MomentKeywords.new(@moment).call - @filter_tags = @matched_tags.uniq.map do |t| - "filter[]=#{t}&" - end - @filter_tags = @filter_tags.join + # @matched_tags = ResourceRecommendations.new(@moment).matched_tags + # @filter_tags = @matched_tags.uniq.map do |t| + # "filter[]=#{t}&" + # end + # @filter_tags = @filter_tags.join + @resources_tags = resources_url_tags end # GET /moments/new diff --git a/app/helpers/moments_helper.rb b/app/helpers/moments_helper.rb index a9eab2a843..bcdd56d6d8 100644 --- a/app/helpers/moments_helper.rb +++ b/app/helpers/moments_helper.rb @@ -107,4 +107,12 @@ def get_present_object(element) moods: element&.mood_names_and_slugs } end + + def resources_url_tags + matched_tags = ResourceRecommendations.new(@moment).matched_tags + filter_tags = matched_tags.uniq.map do |t| + "filter[]=#{t}&" + end + filter_tags.join + end end diff --git a/app/views/moments/show.html.erb b/app/views/moments/show.html.erb index 72d84d1331..b05dfff163 100644 --- a/app/views/moments/show.html.erb +++ b/app/views/moments/show.html.erb @@ -50,7 +50,7 @@ <% @resources.each do |item| %>
  • <%= link_to item['name'], item['link'] %>
  • <%end %> -
  • <%= link_to 'More...', "/resources?#{@filter_tags}" %>
  • +
  • <%= link_to 'More...', "/resources?#{@resources_tags}" %>
  • <% end %> diff --git a/spec/services/resource_recommendations_spec.rb b/spec/services/resource_recommendations_spec.rb index cb5e705354..dffeae4ee6 100644 --- a/spec/services/resource_recommendations_spec.rb +++ b/spec/services/resource_recommendations_spec.rb @@ -13,7 +13,7 @@ expect(resources).to eq(available_resource) end it 'does not return any matched resources' do - available_resource2 = [{'tags'=> ['self_care', 'anonymous', 'ios', 'communities']}] + available_resource2 = [{'tags'=> ['self-injury', 'tech industry', 'anonymous', 'ios', 'communities']}] allow(JSON).to receive(:parse) { available_resource2 } expect(resources).not_to eq(available_resource2) end