diff --git a/app/controllers/banners_controller.rb b/app/controllers/banners_controller.rb index c8f037d9e..1eea0cfb1 100644 --- a/app/controllers/banners_controller.rb +++ b/app/controllers/banners_controller.rb @@ -29,7 +29,7 @@ def create authorize! @banner if @banner.save - redirect_to banners_path, notice: "Banner was successfully created." + redirect_to @banner, notice: "Banner was successfully created." else set_form_variables render :new, status: :unprocessable_content @@ -39,7 +39,7 @@ def create def update authorize! @banner if @banner.update(banner_params) - redirect_to banners_path, notice: "Banner was successfully updated.", status: :see_other + redirect_to @banner, notice: "Banner was successfully updated.", status: :see_other else set_form_variables render :edit, status: :unprocessable_content diff --git a/app/controllers/community_news_controller.rb b/app/controllers/community_news_controller.rb index 3b0a922a4..448c9e18c 100644 --- a/app/controllers/community_news_controller.rb +++ b/app/controllers/community_news_controller.rb @@ -67,7 +67,7 @@ def create end if success - redirect_to community_news_index_path, + redirect_to @community_news, notice: "Community news was successfully created." else @community_news = @community_news.decorate @@ -91,7 +91,7 @@ def update end if success - redirect_to community_news_index_path, + redirect_to @community_news, notice: "Community news was successfully updated.", status: :see_other else set_form_variables diff --git a/app/controllers/event_registrations_controller.rb b/app/controllers/event_registrations_controller.rb index 39f963ab7..aa97fb311 100644 --- a/app/controllers/event_registrations_controller.rb +++ b/app/controllers/event_registrations_controller.rb @@ -57,7 +57,7 @@ def create respond_to do |format| format.html { - redirect_to event_registrations_path, + redirect_to @event_registration, notice: "Registration created." } end @@ -74,7 +74,7 @@ def create def update authorize! @event_registration if @event_registration.update(event_registration_params) - redirect_to event_registrations_path, notice: "Registration was successfully updated.", status: :see_other + redirect_to @event_registration, notice: "Registration was successfully updated.", status: :see_other else set_form_variables render :edit, status: :unprocessable_content diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 2ac026004..6ca5336c0 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -48,7 +48,7 @@ def create respond_to do |format| if success - format.html { redirect_to events_path, notice: "Event was successfully created." } + format.html { redirect_to @event, notice: "Event was successfully created." } format.json { render :show, status: :created, location: @event } else set_form_variables @@ -74,7 +74,7 @@ def update respond_to do |format| if success - format.html { redirect_to events_path, notice: "Event was successfully updated." } + format.html { redirect_to @event, notice: "Event was successfully updated." } format.json { render :show, status: :ok, location: @event } else set_form_variables diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index bf384ad27..b9cf6f214 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -90,7 +90,7 @@ def create authorize! @organization if @organization.save - redirect_to organizations_path, notice: "Organization was successfully created." + redirect_to @organization, notice: "Organization was successfully created." else set_form_variables render :new, status: :unprocessable_content diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index f2f5b130c..accd5b846 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -33,7 +33,7 @@ def create authorize! @quote if @quote.save - redirect_to quotes_path, notice: "Quote was successfully created." + redirect_to @quote, notice: "Quote was successfully created." else set_form_variables render :new, status: :unprocessable_content @@ -43,7 +43,7 @@ def create def update authorize! @quote if @quote.update(quote_params) - redirect_to quotes_path, notice: "Quote was successfully updated.", status: :see_other + redirect_to @quote, notice: "Quote was successfully updated.", status: :see_other else set_form_variables render :edit, status: :unprocessable_content diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb index 92a9003e0..59642507e 100644 --- a/app/controllers/resources_controller.rb +++ b/app/controllers/resources_controller.rb @@ -79,7 +79,7 @@ def create end if success - redirect_to resource_path(@resource) + redirect_to @resource else @resource = @resource.decorate set_form_variables @@ -106,7 +106,7 @@ def update if success flash[:notice] = "Resource updated." - redirect_to resource_path(@resource) + redirect_to @resource else set_form_variables flash[:alert] = "Failed to update Resource." diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 2e958b6c4..a09814f1e 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -78,7 +78,7 @@ def create end if success - redirect_to stories_path, notice: "Story was successfully created." + redirect_to @story, notice: "Story was successfully created." else @story = @story.decorate set_form_variables @@ -104,7 +104,7 @@ def update end if success - redirect_to stories_path, notice: "Story was successfully updated.", status: :see_other + redirect_to @story, notice: "Story was successfully updated.", status: :see_other else @story = @story.decorate set_form_variables diff --git a/app/controllers/story_ideas_controller.rb b/app/controllers/story_ideas_controller.rb index 69746ec0d..c9910e59f 100644 --- a/app/controllers/story_ideas_controller.rb +++ b/app/controllers/story_ideas_controller.rb @@ -56,8 +56,8 @@ def create if success flash[:notice] = "StoryIdea was successfully created." - if allowed_to?(:index?, StoryIdea) - redirect_to story_ideas_path + if allowed_to?(:show?, @story_idea) + redirect_to @story_idea else redirect_to root_path end @@ -85,8 +85,8 @@ def update if success flash[:notice] = "StoryIdea was successfully updated." - if allowed_to?(:index?, StoryIdea) - redirect_to story_ideas_path, status: :see_other + if allowed_to?(:show?, @story_idea) + redirect_to @story_idea, status: :see_other else redirect_to root_path, status: :see_other end diff --git a/app/controllers/tutorials_controller.rb b/app/controllers/tutorials_controller.rb index 0673a9349..bc612de81 100644 --- a/app/controllers/tutorials_controller.rb +++ b/app/controllers/tutorials_controller.rb @@ -36,7 +36,7 @@ def create authorize! @tutorial if @tutorial.save - redirect_to tutorials_path, notice: "Tutorial was successfully created." + redirect_to @tutorial, notice: "Tutorial was successfully created." else @tutorial = @tutorial.decorate set_form_variables @@ -47,7 +47,7 @@ def create def update authorize! @tutorial if @tutorial.update(tutorial_params) - redirect_to tutorials_path, notice: "Tutorial was successfully updated.", status: :see_other + redirect_to @tutorial, notice: "Tutorial was successfully updated.", status: :see_other else @tutorial = @tutorial.decorate set_form_variables diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6d47ddc22..ffa10de77 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -80,7 +80,7 @@ def create if @user.save # @user.notifications.create(notification_type: 0) - redirect_to users_path(search: @user.email), notice: "User was successfully created." + redirect_to @user, notice: "User was successfully created." else set_form_variables render :new, status: :unprocessable_content @@ -114,7 +114,7 @@ def update bypass_sign_in(@user) if @user == current_user notice = "User was successfully updated." notice += " A confirmation email has been sent to #{@user.unconfirmed_email}." if @user.unconfirmed_email.present? && @user.saved_change_to_unconfirmed_email? - redirect_to users_path, notice: notice + redirect_to @user, notice: notice else flash[:alert] = "Unable to update user." set_form_variables diff --git a/app/controllers/workshop_ideas_controller.rb b/app/controllers/workshop_ideas_controller.rb index 86f8de0ae..b1655523d 100644 --- a/app/controllers/workshop_ideas_controller.rb +++ b/app/controllers/workshop_ideas_controller.rb @@ -33,8 +33,8 @@ def create notification_type: 0) flash[:notice] = "Workshop idea was successfully created." - if allowed_to?(:index?, WorkshopIdea) - redirect_to workshop_ideas_path + if allowed_to?(:show?, @workshop_idea) + redirect_to @workshop_idea else redirect_to root_path end @@ -53,7 +53,7 @@ def edit def update authorize! @workshop_idea if @workshop_idea.update(workshop_idea_params) - redirect_to workshop_ideas_path, notice: "Workshop idea was successfully updated.", status: :see_other + redirect_to @workshop_idea, notice: "Workshop idea was successfully updated.", status: :see_other else set_form_variables render :edit, status: :unprocessable_content diff --git a/app/controllers/workshop_variation_ideas_controller.rb b/app/controllers/workshop_variation_ideas_controller.rb index 8e3ce73b2..cc5a66b32 100644 --- a/app/controllers/workshop_variation_ideas_controller.rb +++ b/app/controllers/workshop_variation_ideas_controller.rb @@ -51,8 +51,8 @@ def create flash[:notice] = "Workshop variation idea was successfully created." if params[:from] == "workshop_show" && @workshop_variation_idea.workshop.present? redirect_to workshop_path(@workshop_variation_idea.workshop, anchor: "workshopVariations") and return - elsif allowed_to?(:index?, WorkshopVariationIdea) - redirect_to workshop_variation_ideas_path and return + elsif allowed_to?(:show?, @workshop_variation_idea) + redirect_to @workshop_variation_idea and return else redirect_to root_path and return end @@ -65,7 +65,7 @@ def create def update authorize! @workshop_variation_idea if @workshop_variation_idea.update(workshop_variation_idea_params) - redirect_to workshop_variation_ideas_path, notice: "Workshop variation idea was successfully updated.", status: :see_other + redirect_to @workshop_variation_idea, notice: "Workshop variation idea was successfully updated.", status: :see_other else set_form_variables render :edit, status: :unprocessable_content diff --git a/app/controllers/workshop_variations_controller.rb b/app/controllers/workshop_variations_controller.rb index 36724beac..a38257deb 100644 --- a/app/controllers/workshop_variations_controller.rb +++ b/app/controllers/workshop_variations_controller.rb @@ -44,8 +44,8 @@ def create flash[:notice] = "Workshop Variation has been created." if params[:from] == "workshop_show" && @workshop_variation.workshop.present? redirect_to workshop_path(@workshop_variation.workshop, anchor: "variation-#{@workshop_variation.id}") and return - elsif allowed_to?(:index?, WorkshopVariation) - redirect_to workshop_variations_path(sort: "created") and return + elsif allowed_to?(:show?, @workshop_variation) + redirect_to @workshop_variation and return else redirect_to root_path and return end @@ -82,7 +82,7 @@ def update if @workshop_variation.update(workshop_variation_params) flash[:notice] = "Workshop Variation updated successfully." - redirect_to workshop_variations_path + redirect_to @workshop_variation else set_form_variables flash[:alert] = "Unable to update Workshop Variation." diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 08786c062..e3b8ad30a 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -107,7 +107,7 @@ def create if success flash[:notice] = "Workshop created successfully." - redirect_to workshops_path(sort: "created") + redirect_to @workshop else set_form_variables flash.now[:alert] = "Unable to save the workshop." @@ -165,7 +165,7 @@ def update if success flash[:notice] = "Workshop updated successfully." - redirect_to workshops_path + redirect_to @workshop else set_form_variables flash[:alert] = "Unable to update the workshop." diff --git a/spec/requests/banners_spec.rb b/spec/requests/banners_spec.rb index 6033ce5fe..359250707 100644 --- a/spec/requests/banners_spec.rb +++ b/spec/requests/banners_spec.rb @@ -69,9 +69,9 @@ }.to change(Banner, :count).by(1) end - it "redirects to the banners index" do + it "redirects to the created banner" do post banners_url, params: { banner: valid_attributes } - expect(response).to redirect_to(banners_url) + expect(response).to redirect_to(banner_url(Banner.last)) end end @@ -104,11 +104,11 @@ skip("Add assertions for updated state") end - it "redirects to the banners index" do + it "redirects to the updated banner" do banner = Banner.create! valid_attributes patch banner_url(banner), params: { banner: new_attributes } banner.reload - expect(response).to redirect_to(banners_url) + expect(response).to redirect_to(banner_url(banner)) end end diff --git a/spec/requests/community_news_spec.rb b/spec/requests/community_news_spec.rb index c88ceb769..f35f60621 100644 --- a/spec/requests/community_news_spec.rb +++ b/spec/requests/community_news_spec.rb @@ -111,9 +111,9 @@ }.to change(CommunityNews, :count).by(1) end - it "redirects to community_news index" do + it "redirects to the created community news" do post community_news_index_url, params: { community_news: valid_attributes } - expect(response).to redirect_to(community_news_index_url) + expect(response).to redirect_to(community_news_url(CommunityNews.last)) end end @@ -146,11 +146,11 @@ skip("Add assertions for updated state") end - it "redirects to the community_news index" do + it "redirects to the updated community news" do community_news = CommunityNews.create! valid_attributes patch community_news_url(community_news), params: { community_news: new_attributes } community_news.reload - expect(response).to redirect_to(community_news_index_url) + expect(response).to redirect_to(community_news_url(community_news)) end end diff --git a/spec/requests/event_registrations_spec.rb b/spec/requests/event_registrations_spec.rb index ff5465fdc..c3eafaa8a 100644 --- a/spec/requests/event_registrations_spec.rb +++ b/spec/requests/event_registrations_spec.rb @@ -75,7 +75,7 @@ patch event_registration_path(existing_registration), params: { event_registration: { event_id: new_event.id } } - expect(response).to redirect_to(event_registrations_path) + expect(response).to redirect_to(event_registration_path(existing_registration)) expect(existing_registration.reload.event_id).to eq(new_event.id) end end diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index 648e3ddfb..7990a3a9e 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -91,9 +91,9 @@ }.to change(Event, :count).by(1) end - it "redirects" do + it "redirects to the created event" do post events_path, params: valid_params - expect(response).to redirect_to(events_path) + expect(response).to redirect_to(event_url(Event.last)) end it "stores start_date/end_date in UTC when created by user in Pacific time zone" do @@ -110,8 +110,8 @@ public: true } } - expect(response).to redirect_to(events_url) created = Event.order(created_at: :desc).first + expect(response).to redirect_to(event_url(created)) expect(created.start_date.utc).to eq(Time.utc(2025, 6, 15, 19, 0, 0)) expect(created.end_date.utc).to eq(Time.utc(2025, 6, 15, 20, 0, 0)) end @@ -129,8 +129,8 @@ public: true } } - expect(response).to redirect_to(events_url) created = Event.order(created_at: :desc).first + expect(response).to redirect_to(event_url(created)) expect(created.start_date.utc).to eq(Time.utc(2025, 6, 15, 19, 0, 0)) expect(created.end_date.utc).to eq(Time.utc(2025, 6, 15, 20, 0, 0)) end diff --git a/spec/requests/organizations_spec.rb b/spec/requests/organizations_spec.rb index fedbad5b8..ef6866730 100644 --- a/spec/requests/organizations_spec.rb +++ b/spec/requests/organizations_spec.rb @@ -70,9 +70,9 @@ }.to change(Organization, :count).by(1) end - it "redirects to the organizations index" do + it "redirects to the created organization" do post organizations_url, params: { organization: valid_attributes } - expect(response).to redirect_to(organizations_url) + expect(response).to redirect_to(organization_url(Organization.last)) end end diff --git a/spec/requests/stories_spec.rb b/spec/requests/stories_spec.rb index 64a341ece..fea2ba38c 100644 --- a/spec/requests/stories_spec.rb +++ b/spec/requests/stories_spec.rb @@ -67,7 +67,7 @@ post stories_url, params: { story: base_attributes } }.to change(Story, :count).by(1) - expect(response).to redirect_to(stories_path) + expect(response).to redirect_to(story_url(Story.last)) end end end diff --git a/spec/requests/story_ideas_spec.rb b/spec/requests/story_ideas_spec.rb index e5fe286cb..4a2a6d891 100644 --- a/spec/requests/story_ideas_spec.rb +++ b/spec/requests/story_ideas_spec.rb @@ -62,7 +62,7 @@ story_idea = create(:story_idea) patch story_idea_url(story_idea), params: { story_idea: { title: "Updated Title" } } - expect(response).to redirect_to(story_ideas_url) + expect(response).to redirect_to(story_idea_url(story_idea)) expect(story_idea.reload.title).to eq("Updated Title") end end @@ -115,9 +115,9 @@ }.to change(StoryIdea, :count).by(1) end - it "redirects to root after create" do + it "redirects to show after create" do post story_ideas_url, params: { story_idea: valid_attributes } - expect(response).to redirect_to(root_path) + expect(response).to redirect_to(story_idea_url(StoryIdea.last)) end it "assigns current_user as owner" do diff --git a/spec/requests/tutorials_spec.rb b/spec/requests/tutorials_spec.rb index 3f6f7bea4..5ea1f478d 100644 --- a/spec/requests/tutorials_spec.rb +++ b/spec/requests/tutorials_spec.rb @@ -77,9 +77,9 @@ }.to change(Tutorial, :count).by(1) end - it "redirects to the tutorials index" do + it "redirects to the created tutorial" do post tutorials_url, params: { tutorial: valid_attributes } - expect(response).to redirect_to(tutorials_url) + expect(response).to redirect_to(tutorial_url(Tutorial.last)) end end @@ -112,11 +112,11 @@ skip("Add assertions for updated state") end - it "redirects to the tutorials index" do + it "redirects to the updated tutorial" do tutorial = Tutorial.create! valid_attributes patch tutorial_url(tutorial), params: { tutorial: new_attributes } tutorial.reload - expect(response).to redirect_to(tutorials_url) + expect(response).to redirect_to(tutorial_url(tutorial)) end end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index d30d28e12..07aa3c142 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -170,9 +170,9 @@ }.to change(User, :count).by(1) end - it "redirects to index with search params" do + it "redirects to the created user" do post users_url, params: { user: valid_attributes } - expect(response).to redirect_to(users_url(search: valid_attributes[:email])) + expect(response).to redirect_to(user_url(User.last)) end end @@ -224,9 +224,9 @@ expect(user.unconfirmed_email).to eq(new_attributes[:email]) end - it "redirects to index" do + it "redirects to the updated user" do patch user_url(user), params: { user: new_attributes } - expect(response).to redirect_to(users_url) + expect(response).to redirect_to(user_url(user)) end it "permits and updates time_zone" do diff --git a/spec/requests/workshop_ideas_spec.rb b/spec/requests/workshop_ideas_spec.rb index d7875db08..49ceae05c 100644 --- a/spec/requests/workshop_ideas_spec.rb +++ b/spec/requests/workshop_ideas_spec.rb @@ -76,7 +76,7 @@ post workshop_ideas_path, params: { workshop_idea: valid_attributes } }.to change(WorkshopIdea, :count).by(1) - expect(response).to redirect_to(workshop_ideas_path) + expect(response).to redirect_to(workshop_idea_path(WorkshopIdea.last)) end end @@ -88,7 +88,7 @@ params: { workshop_idea: { title: "Updated Title" } } expect(idea.reload.title).to eq("Updated Title") - expect(response).to redirect_to(workshop_ideas_path) + expect(response).to redirect_to(workshop_idea_path(idea)) end end diff --git a/spec/requests/workshop_variation_ideas_spec.rb b/spec/requests/workshop_variation_ideas_spec.rb index 6c187e623..d8e0ec64b 100644 --- a/spec/requests/workshop_variation_ideas_spec.rb +++ b/spec/requests/workshop_variation_ideas_spec.rb @@ -79,7 +79,7 @@ post workshop_variation_ideas_path, params: { workshop_variation_idea: valid_attributes } }.to change(WorkshopVariationIdea, :count).by(1) - expect(response).to redirect_to(workshop_variation_ideas_path) + expect(response).to redirect_to(workshop_variation_idea_path(WorkshopVariationIdea.last)) end it "sends a notification" do @@ -113,7 +113,7 @@ params: { workshop_variation_idea: { name: "Updated Name" } } expect(idea.reload.name).to eq("Updated Name") - expect(response).to redirect_to(workshop_variation_ideas_path) + expect(response).to redirect_to(workshop_variation_idea_path(idea)) end end @@ -173,7 +173,7 @@ params: { workshop_variation_idea: valid_attributes } }.to change(WorkshopVariationIdea, :count).by(1) - expect(response).to redirect_to(root_path) + expect(response).to redirect_to(workshop_variation_idea_path(WorkshopVariationIdea.last)) end end diff --git a/spec/requests/workshop_variations_spec.rb b/spec/requests/workshop_variations_spec.rb index e4422860a..1592761a1 100644 --- a/spec/requests/workshop_variations_spec.rb +++ b/spec/requests/workshop_variations_spec.rb @@ -69,7 +69,7 @@ new_variation = WorkshopVariation.last expect(new_variation.workshop_variation_idea_id).to eq(workshop_variation_idea.id) expect(new_variation.name).to eq(workshop_variation_idea.name) - expect(response).to redirect_to(workshop_variations_path(sort: "created")) + expect(response).to redirect_to(workshop_variation_path(WorkshopVariation.last)) end it "attaches assets from idea when promote_idea_assets is true" do @@ -170,7 +170,7 @@ post workshop_variations_path, params: { workshop_variation: valid_attributes } }.to change(WorkshopVariation, :count).by(1) - expect(response).to redirect_to(workshop_variations_path(sort: "created")) + expect(response).to redirect_to(workshop_variation_path(WorkshopVariation.last)) end end @@ -202,7 +202,7 @@ params: { workshop_variation: { name: "Updated Name" } } expect(variation.reload.name).to eq("Updated Name") - expect(response).to redirect_to(workshop_variations_path) + expect(response).to redirect_to(workshop_variation_path(variation)) end end end diff --git a/spec/system/person_submits_story_test.rb b/spec/system/person_submits_story_test.rb index 229b29179..733903077 100644 --- a/spec/system/person_submits_story_test.rb +++ b/spec/system/person_submits_story_test.rb @@ -54,7 +54,7 @@ expect(page).to have_content("Story was successfully created.") expect(page).to have_content("Healing Through Art") - expect(page).to have_current_path(stories_path) + expect(page).to have_current_path(story_path(Story.last)) end it "can cancel the form" do click_link "Cancel" diff --git a/spec/system/stories_spec.rb b/spec/system/stories_spec.rb index bd0139e44..6e934df90 100644 --- a/spec/system/stories_spec.rb +++ b/spec/system/stories_spec.rb @@ -123,7 +123,8 @@ end expect(page).to have_content("Story was successfully updated.") - expect(page).to have_css("turbo-frame#story_results", text: "A New Title") + expect(page).to have_current_path(story_path(story)) + expect(page).to have_content("A New Title") end end end