Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preload using with_translations #92

Merged
merged 5 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree', github: 'spree/spree', branch: 'main'
gem 'spree_frontend', github: 'spree/spree', branch: 'main'
gem 'spree_backend', github: 'spree/spree', branch: 'main'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'

gemspec
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'spree/testing_support/common_rake'
require 'spree/testing_support/extension_rake'

Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new
Expand All @@ -20,5 +20,5 @@ end
desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'spree_globalize'
Rake::Task['common:test_app'].invoke
Rake::Task['extension:test_app'].invoke
end
2 changes: 1 addition & 1 deletion app/models/concerns/spree_globalize/translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def ransack(params = {}, options = {})

# preload translations
def spree_base_scopes
super.includes(:translations).references(:translations)
super.with_translations
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/spree_4_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem 'spree', '~> 4.2.0.rc4'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'main'

gemspec path: '../'
8 changes: 5 additions & 3 deletions gemfiles/spree_master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

source "https://rubygems.org"

gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree', github: 'spree/spree', branch: 'main'
gem 'spree_frontend', github: 'spree/spree', branch: 'main'
gem 'spree_backend', github: 'spree/spree', branch: 'main'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'main'

gemspec path: '../'
gemspec path: '../'
6 changes: 3 additions & 3 deletions spec/features/translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
end

context 'product' do
let!(:store) { create(:store, default: true, default_locale: 'pt-BR', supported_locales: 'pt-BR') }
let!(:store) { create(:store, default: true, default_locale: 'pt-BR', supported_locales: 'pt-BR', url:'http://www.example.com') }
let!(:product) do
create(:product,
name: 'Antimatter',
Expand All @@ -22,12 +22,12 @@
)
end

scenario 'displays translated product page' do
scenario 'displays translated product page', js: true do
visit '/products/antimatter'
expect(page.title).to have_content('Antimatéria')
end

scenario 'displays translated products list' do
scenario 'displays translated products list', js: true do
visit '/products'
expect(page).to have_content('Antimatéria')
end
Expand Down