Correctly handle trying to edit not existing settings tab (#1011)

This commit is contained in:
Frédéric Planté 2018-10-26 19:06:55 +02:00 committed by Ben Halpern
parent bddfc8a69d
commit 2b2a7afb03
2 changed files with 7 additions and 0 deletions

View file

@ -173,6 +173,8 @@ class UsersController < ApplicationController
%0A
YOUR-DEV-USERNAME-HERE
HEREDOC
else
not_found unless @tab_list.map { |t| t.downcase.gsub(" ", "-") }.include? @tab
end
end
end

View file

@ -21,6 +21,11 @@ RSpec.describe "UserSettings", type: :request do
end
end
it "handles unknown settings tab properly" do
expect { get "/settings/does-not-exist" }.
to raise_error(ActionController::RoutingError)
end
it "doesn't let user access membership if user has no monthly_dues" do
get "/settings/membership"
expect(response.body).not_to include("Settings for")