Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSpec & multitenancy. Preferences test should fail
Due to the `Capybara-shared-connection` issue, we cannot provide multitenant feature specs. See influitive/apartment#444 Tried this, but seems not working... :( ....... Include rspec-rails gem and install with: $ rails g rspec:install *also add standard Rails test for preferences (skipped)
- Loading branch information
Flavio Auciello
committed
Sep 28, 2018
1 parent
9f7ca93
commit 2357f12
Showing
10 changed files
with
406 additions
and
0 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 @@ | ||
--require spec_helper |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<nav class="columns sixteen"> | ||
<ul id="main-nav-bar" class="inline" data-hook> | ||
<li id="home-link" data-hook><%= link_to t('spree.home'), spree.root_path %></li> | ||
<li id="mails-from" class="testing">Contact us at <%= Spree::Config[:mails_from] %></li> | ||
<li id="link-to-cart" data-hook> | ||
<noscript> | ||
<%= link_to t('spree.cart'), spree.cart_path %> | ||
</noscript> | ||
| ||
</li> | ||
</ul> | ||
<script>Spree.fetch_cart('<%= j spree.cart_link_path %>')</script> | ||
</nav> |
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,46 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature Spree::Preferences, type: :feature do | ||
TENANTS_EXPECTATIONS = { | ||
latina_shop: { | ||
mails_from: 'store@latina-shop.com', | ||
locale: :en | ||
}, | ||
pescara_shop: { | ||
mails_from: 'store@pescara-shop.com', | ||
locale: :it | ||
} | ||
} | ||
|
||
NebulabShop::Stores.each do |tenant, domain| | ||
|
||
describe "when visiting #{tenant}", tenant: tenant do | ||
let(:mails_from) { tenant_expectation_for(tenant, :mails_from) } | ||
let(:locale) { tenant_expectation_for(tenant, :locale) } | ||
|
||
before do | ||
Capybara.app_host = "http://#{domain}" | ||
visit spree.products_path | ||
end | ||
|
||
it "sets the correct tenant" do | ||
expect(Apartment::Tenant.current).to eq(tenant) | ||
end | ||
|
||
it "sets the correct locale" do | ||
expect(I18n.locale).to eq(locale) | ||
end | ||
|
||
it 'fetch Solidus preferences from the correct tenant' do | ||
expect(page).to have_css("li#mails-from.testing", text: "Contact us at #{mails_from}") | ||
end | ||
end | ||
|
||
end | ||
|
||
private | ||
|
||
def tenant_expectation_for(tenant, key) | ||
TENANTS_EXPECTATIONS[tenant][key.to_sym] | ||
end | ||
end |
Oops, something went wrong.