File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 11class SettingsController < ApplicationController
22 def provider
3- provider = provider_scope . find_by ( id : provider_params [ :id ] )
3+ provider = provider_scope . find ( provider_params [ :id ] )
44 cookies . signed [ :current_provider_id ] = provider . id if provider
55 redirect_to request . referer || root_path
66 end
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def archive
4646 private
4747
4848 def other_available_providers
49- return unless Current . user . providers . any?
49+ return [ ] unless Current . user . providers . any?
5050
5151 Current . user . providers . where . not ( id : current_provider . id )
5252 end
@@ -69,8 +69,15 @@ def set_topic
6969 def scope
7070 @scope ||= if Current . user . is_admin?
7171 Topic . all
72- else
72+ elsif current_provider . present?
7373 current_provider . topics
74+ else
75+ Current . user . topics
7476 end . includes ( :language , :provider )
7577 end
78+
79+ def topics_title
80+ current_provider . present? ? "#{ current_provider . name } /topics" : "Topics"
81+ end
82+ helper_method :topics_title
7683end
Original file line number Diff line number Diff line change 77 <%= turbo_frame_tag "topics" do %>
88 < div class ="card ">
99 < div class ="card-header d-flex justify-content-between align-items-center ">
10- < h2 class ="card-title "> <%= current_provider . name %> 's topics </ h2 >
10+ < h2 class ="card-title "> <%= topics_title %> </ h2 >
1111 <%= link_to new_topic_path , class : "btn btn-primary" do %>
1212 < i class ="bi bi-plus "> </ i > Add New Topic
1313 <% end %>
Original file line number Diff line number Diff line change 99
1010 context "when provider cannot be found" do
1111 it "does not update current provider" do
12- put provider_settings_url , params : { id : provider . id }
12+ put provider_settings_url , params : { provider : { id : provider . id } }
1313
1414 expect ( response ) . to have_http_status ( :not_found )
1515 end
2121 end
2222
2323 it "updates current provider" do
24- put provider_settings_url , params : { id : provider . id }
24+ put provider_settings_url , params : { provider : { id : provider . id } }
2525
2626 signed_cookies = ActionDispatch ::Request . new ( Rails . application . env_config ) . cookie_jar
2727
You can’t perform that action at this time.
0 commit comments