-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to DomainContraint to prevent database call per request
- Switches logic to match on non event host domain set in ENV variable rather than website domains stored in DB - Moves config/initializers/domain_constraint.rb to app/constraints folder - Set Rails configuration events_hosts value from EVENTS_HOSTS env variable with fallback defaults for non production environments - Uses lvh.me as domain to more accurately test domain constraint logic in feature specs
- Loading branch information
Showing
11 changed files
with
66 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class DomainConstraint | ||
def matches?(request) | ||
return false unless request.domain | ||
|
||
!Rails.configuration.events_hosts.match?(request.domain) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
require 'support/helpers/session_helpers' | ||
require 'support/helpers/form_helpers' | ||
require 'support/helpers/domain_helpers' | ||
|
||
RSpec.configure do |config| | ||
config.include Features::SessionHelpers, type: :feature | ||
config.include Features::FormHelpers, type: :feature | ||
config.include Features::DomainHelpers, type: :feature | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Features | ||
module DomainHelpers | ||
def with_domain(host) | ||
original_host = Capybara.app_host | ||
Capybara.app_host = "http://#{host}" | ||
yield | ||
ensure | ||
Capybara.app_host = original_host | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters