-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[RFC] Pull rails dependency out of core into solidus_rails #2236
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two minor nits which I don't care whether they're addressed. Great work, this will greatly speed up development!
solidus_rails/solidus_rails.gemspec
Outdated
s.platform = Gem::Platform::RUBY | ||
s.name = 'solidus_rails' | ||
s.version = Spree.solidus_version | ||
s.summary = 'Provides the rails glue for the legacy solidus frontend/backend/api' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to call these legacy
just yet? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
core/lib/spree.rb
Outdated
# end | ||
# | ||
# This method is defined within the core gem on purpose. | ||
# Some people may only wish to use the Core part of Spree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Spree/Solidus ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just a move, but updated.
|
||
s.add_dependency 'solidus_core', s.version | ||
|
||
s.add_dependency 'rails', '~> 5.1.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be split out to just actionmailer and activerecord.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will once the deps are actually removed, aye. There are still lots of rails calls inside the codebase (and we still have the engine in there).
My initial feeling towards this is 👎 I don't see any benefit to making these changes. Furthermore I expect this will be confusing to users as it is already confusing to me. Even after all these changes, As for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be done. Let's not approve PRs before they can even build.
Yea, it'll be a fair number of more changes before I can actually remove the rails dep from solidus_core, but without this work that'll never be possible of course. |
dcf85f4
to
0a1011c
Compare
core/spec/rails_helper.rb
Outdated
config.infer_spec_type_from_file_location! | ||
# set paperclip to interpolate rails_root, since we don't have one | ||
# sans rails | ||
Paperclip.interpolates :rails_root do |attachment, style| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - attachment. You can omit all the arguments if you don't care about them.
Unused block argument - style. You can omit all the arguments if you don't care about them.
31b56f4
to
afba33f
Compare
max = preferred_max_items.to_i | ||
quantity.times do |i| | ||
# check max value to avoid divide by 0 errors | ||
if (max == 0 && i == 0) || (max > 0) && (i % max == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use max.zero? instead of max == 0.
Use i.zero? instead of i == 0.
Use (i % max).zero? instead of i % max == 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed this rubocop annoyance with #2314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll end up pulling this commit out, as I sent it separably as #2312
|
||
return BigDecimal.new(0) if items_count == 0 | ||
return BigDecimal.new(0) if items_count == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use items_count.zero? instead of items_count == 0.
core/script/rails
Outdated
ENGINE_PATH = File.expand_path('../../lib/spree/core/engine', __FILE__) | ||
|
||
require 'rails/all' | ||
require 'rails/engine/commands' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably cherry-pick this out into another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pulled this out entirely, can be dealt with later
ee54392
to
9ce513c
Compare
ActiveJob::Base.queue_adapter = :test | ||
|
||
RSpec.configure do |config| | ||
config.fixture_path = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use dir to get an absolute path to the current file's directory.
solidus_rails/spec/rails_helper.rb
Outdated
begin | ||
require File.expand_path("../dummy/config/environment", __FILE__) | ||
rescue LoadError | ||
$stderr.puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use warn instead of $stderr.puts.
config.use_transactional_fixtures = true | ||
# set paperclip to interpolate rails_root, since we don't have one | ||
# sans rails | ||
Paperclip.interpolates :rails_root do |attachment, style| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - attachment. You can omit all the arguments if you don't care about them.
Unused block argument - style. You can omit all the arguments if you don't care about them.
10c9519
to
f2877a1
Compare
@cbrunsdon oh man, looking at that, I feel like Solidus Core should be ActiveSolidus and Solidus Rails should be ActionSolidus XD |
We use mattr_accessor, defined in active support here, so we may as well declare that we use it.
It doesn't take much for us to require our dependencies, so lets do it.
A small change to add more explicit requires in the stack
This is a transitionary step to remove rails_helper entirely, but it sets up the test env for rails-like settings, without needing to run test_app or boot an unused rails app.
As these are rendering full messages, they need a view path in order to render a mailer, so we need more to set up for testing.
Our models use activejob, which requires a globalid setup in order to create jobs
This makes our runs look more like rails defaults, sets default settings for test.
We don't have rails root set as we're not running a full rails app, so we'll need to set it ourselves.
These tests are heavily dependent on the default config getting set up in the rails initializer.
really_destroy! does weird things, this should maybe still be flagged as persisted? For sure, though, trying to reload should cause an activerecord not found.
We don't have much work to do for test, app, just need to run the migrations. We are re-using test_app for compatability, but might want to change this in the future.
Need to test the code I'm pushing out of core.
As core no longer runs (most) of rails, we can pull these out now and just add them to the rails projects
None of this is needed/used by core, but is required by our rails apps, so pushing it into solidus_rails.
As all these sub-gems require solidus_rails, we load it early.
We no longer run test_app, so there isn't a clearly great place to run migrations, but this will do for now.
084f4a4
to
863db95
Compare
@@ -0,0 +1,34 @@ | |||
require 'active_support/core_ext/module/attribute_accessors' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't name a file spree.rb, because of the other file of the same name. Even with the require_relative it has potential to cause issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I like the idea of a spree.rb
defining the Spree
module. (independent of the rest of these changes). Can we look at killing the other one?
I am not a big fan of the "solidus" gem itself doing much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That file doesn't do much, but we should definitely deprecate it before removing it, various extensions and likely stores, which have been upgraded from spree, are expecting that require to require all of Solidus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not super worried about deleting the original without deprecating as I don't think it would create any runtime errors in stores, and could be caught and fixed very easily by anyone reading the changelog.
But now that i sit down and think about it, I'm not 100% sure how/when solidus is usually required into a project.
Anecdotally I grep'd my code folder and we don't have any projects, either inherited or greenfield that do a require 'spree'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I just checked and it looks like we usually get solidus required as part of:
Bundler.require(*Rails.groups)
in config/application.rb's.
I doubt anyone is going to get caught by this, even if they are an old spree upgrade.
Closing this one since there seems to be no one anymore interested and it's a big change that requires some ownership at least. |
Solidus core doesn't need to be a mountable rails engine.
Core only provides its rails engine for use in solidus_frontend, solidus_backend, and solidus_api. By creating a new gem (solidus_rails), and pushing the rails dependencies into it, we can lesson the surface area of core.
This would allow us more room to try other technologies, build smaller modules to enhance core, and allow us to develop significantly faster (without constantly needing a full rails env to do anything). This removes the requirement to run test_app or use the spec/dummy to run tests.
It will also give us a new layer to keep compatibility in with existing _frontend, and _backend while continuing to move core forward (think: pulling out pre-complete-states)
You can see from the db_helper.rb, and the inclusion of standalone_migrations how simple it is to continue to maintain activerecord migrations in core.
This transition will take a while as we move all dependencies to solidus_rails, but should be pretty seamless for anyone currently relying on frontend or backend.
Big TODOs:
Happy for feedback or to discuss this change here, on slack, or over a hangout if anyone wanted to talk face to face.