Created
May 14, 2018 09:15
-
-
Save dapi/34388ffbf65bb784fd095b021d363ec0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Это такой замысловатый спосбо добавить поддомен в запрос для rspec | |
| # | |
| # Использовать: | |
| # | |
| # RSpec.configure do |config| | |
| # config.include ProcessWithRequestSubdomain, type: :controller | |
| # | |
| module ProcessWithRequestSubdomain | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| module WithSubdomain | |
| def process(action, *args) | |
| if kwarg_request?(args) | |
| args.first.deep_merge! params: { subdomain: request.subdomain } if request.subdomain.present? | |
| super(action, *args) | |
| elsif args.count == 1 | |
| args[0] = { method: args[0], params: { subdomain: request.subdomain } } if request.subdomain.present? | |
| super(action, *args) | |
| else | |
| args[1] ||= {} | |
| args[1][:subdomain] = request.subdomain if request.subdomain.present? | |
| super(action, *args) | |
| end | |
| end | |
| end | |
| def new(*) | |
| super.extend(WithSubdomain) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment