diff --git a/Changelog.md b/Changelog.md index e70e51465..86eb81f1b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,12 +2,14 @@ ## Refactor * Remove the 'make contacts in this aspect visible to each other' option [#7769](https://github.com/diaspora/diaspora/pull/7769) +* Remove the requirement to have at least two users to disable the /podmin redirect [#7783](https://github.com/diaspora/diaspora/pull/7783) ## Bug fixes * Prefill conversation form on contacts page only with mutual contacts [#7744](https://github.com/diaspora/diaspora/pull/7744) * Fix profiles sometimes not loading properly in background tabs [#7740](https://github.com/diaspora/diaspora/pull/7740) * Show error message when creating posts with invalid aspects [#7742](https://github.com/diaspora/diaspora/pull/7742) * Fix mention syntax backport for two immediately consecutive mentions [#7777](https://github.com/diaspora/diaspora/pull/7777) +* Fix link to 'make yourself an admin' [#7783](https://github.com/diaspora/diaspora/pull/7783) ## Features * Make public stream accessible for logged out users [#7775](https://github.com/diaspora/diaspora/pull/7775) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index feaddad14..8d24202e8 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -21,7 +21,7 @@ class HomeController < ApplicationController partial_dir.join("_show.html.erb").exist? || partial_dir.join("_show.haml").exist? render :show - elsif User.count > 1 && Role.where(name: "admin").any? + elsif Role.admins.any? render :default else redirect_to podmin_path diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 82cc10711..6f8b8e031 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -6,31 +6,14 @@ describe HomeController, type: :controller do describe "#show" do - it "does not redirect for :html if there are at least 2 users and an admin" do - allow(User).to receive(:count).and_return(2) - allow(Role).to receive_message_chain(:where, :any?).and_return(true) - allow(Role).to receive_message_chain(:where, :exists?).and_return(true) + it "does not redirect for :html if there is at least one admin" do + expect(Role).to receive_message_chain(:admins, :any?).and_return(true) get :show expect(response).not_to be_redirect end - it "redirects to the podmin page for :html if there are less than 2 users" do - allow(User).to receive(:count).and_return(1) - allow(Role).to receive_message_chain(:where, :any?).and_return(true) - get :show - expect(response).to redirect_to(podmin_path) - end - it "redirects to the podmin page for :html if there is no admin" do - allow(User).to receive(:count).and_return(2) - allow(Role).to receive_message_chain(:where, :any?).and_return(false) - get :show - expect(response).to redirect_to(podmin_path) - end - - it "redirects to the podmin page for :html if there are less than 2 users and no admin" do - allow(User).to receive(:count).and_return(0) - allow(Role).to receive_message_chain(:where, :any?).and_return(false) + expect(Role).to receive_message_chain(:admins, :any?).and_return(false) get :show expect(response).to redirect_to(podmin_path) end