Skip to content

Commit

Permalink
Merge pull request #3478 from nebulab/elia/rails-frameworks
Browse files Browse the repository at this point in the history
Only require the necessary Rails frameworks
  • Loading branch information
kennyadsl authored Nov 25, 2020
2 parents f37386e + ed8b7f9 commit 8618504
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 9 deletions.
7 changes: 3 additions & 4 deletions backend/lib/spree/backend.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'rails/all'
require 'spree_core'
require 'spree_api'

require 'jquery-rails'
require 'coffee-rails'
require 'sassc-rails'
Expand All @@ -11,9 +13,6 @@
require 'kaminari'
require 'responders'

require 'spree_core'
require 'spree_api'

require 'spree/backend/action_callbacks'
require 'spree/backend/callbacks'
require 'spree/backend/engine'
21 changes: 21 additions & 0 deletions backend/spec/lib/spree/backend_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spree/backend'

RSpec.describe Spree::Backend do
it 'loads only the necessary Rails Frameworks' do
aggregate_failures do
expect(defined? ActionCable::Engine).to be_falsey
expect(defined? ActionController::Railtie).to be_truthy
expect(defined? ActionMailer::Railtie).to be_truthy
expect(defined? ActionView::Railtie).to be_truthy
expect(defined? ActiveJob::Railtie).to be_truthy
expect(defined? ActiveModel::Railtie).to be_truthy
expect(defined? ActiveRecord::Railtie).to be_truthy
expect(defined? ActiveStorage::Engine).to be_truthy
expect(defined? Rails::TestUnit::Railtie).to be_falsey
expect(defined? Sprockets::Railtie).to be_truthy
end
end
end
10 changes: 9 additions & 1 deletion core/lib/spree/core.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# frozen_string_literal: true

require 'rails/all'
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "active_job/railtie"
require "active_model/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "sprockets/railtie"

require 'acts_as_list'
require 'awesome_nested_set'
require 'cancan'
Expand Down
1 change: 1 addition & 0 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'active_storage/engine'

Rails.env = 'test'

Expand Down
21 changes: 21 additions & 0 deletions core/spec/lib/spree/core_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spree/core'

RSpec.describe Spree::Core do
it 'loads only the necessary Rails Frameworks' do
aggregate_failures do
expect(defined? ActionCable::Engine).to be_falsey
expect(defined? ActionController::Railtie).to be_truthy
expect(defined? ActionMailer::Railtie).to be_truthy
expect(defined? ActionView::Railtie).to be_truthy
expect(defined? ActiveJob::Railtie).to be_truthy
expect(defined? ActiveModel::Railtie).to be_truthy
expect(defined? ActiveRecord::Railtie).to be_truthy
expect(defined? ActiveStorage::Engine).to be_truthy
expect(defined? Rails::TestUnit::Railtie).to be_falsey
expect(defined? Sprockets::Railtie).to be_truthy
end
end
end
1 change: 1 addition & 0 deletions core/spec/lib/spree/event/subscriber_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'active_support/all'
require 'spec_helper'
require 'spree/event'

Expand Down
7 changes: 3 additions & 4 deletions frontend/lib/spree/frontend.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# frozen_string_literal: true

require 'rails/all'
require 'solidus_core'
require 'solidus_api'

require 'jquery-rails'
require 'canonical-rails'
require 'sassc-rails'
require 'font-awesome-rails'
require 'responders'
require 'kaminari'

require 'solidus_core'
require 'solidus_api'

require 'spree/frontend/middleware/seo_assist'
require 'spree/frontend/engine'
21 changes: 21 additions & 0 deletions frontend/spec/lib/spree/frontend_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'spec_helper'
require 'spree/frontend'

RSpec.describe Spree::Frontend do
it 'loads only the necessary Rails Frameworks' do
aggregate_failures do
expect(defined? ActionCable::Engine).to be_falsey
expect(defined? ActionController::Railtie).to be_truthy
expect(defined? ActionMailer::Railtie).to be_truthy
expect(defined? ActionView::Railtie).to be_truthy
expect(defined? ActiveJob::Railtie).to be_truthy
expect(defined? ActiveModel::Railtie).to be_truthy
expect(defined? ActiveRecord::Railtie).to be_truthy
expect(defined? ActiveStorage::Engine).to be_truthy
expect(defined? Rails::TestUnit::Railtie).to be_falsey
expect(defined? Sprockets::Railtie).to be_truthy
end
end
end

0 comments on commit 8618504

Please sign in to comment.