Openfoodnetwork: [Spree 2 Upgrade] Remove references to MailMethod

Created on 14 Nov 2017  路  8Comments  路  Source: openfoodfoundation/openfoodnetwork

What

In Spree 2.0 the MailMethod model no longer exists. See https://guides.spreecommerce.org/release_notes/spree_2_0_0.html#mailmethod-model-no-longer-exists.

We should remove all references to it, most of which are in the specs. This is what a git grep returns now:

app/mailers/spree/base_mailer_decorator.rb:    Spree::MailMethod.current.andand.preferred_mails_from ||
db/migrate/20120327000613_create_mail_methods.rb:class CreateMailMethods < ActiveRecord::Migration
lib/tasks/dev.rake:      Spree::MailMethod.create!(
spec/controllers/spree/admin/orders_controller_spec.rb:            Spree::MailMethod.create!(
spec/controllers/spree/orders_controller_spec.rb:          Spree::MailMethod.create!(
spec/features/consumer/shopping/orders_spec.rb:        Spree::MailMethod.create!(
spec/mailers/order_mailer_spec.rb:    Spree::MailMethod.create!(
spec/mailers/producer_mailer_spec.rb:    Spree::MailMethod.create!(
spec/models/order_cycle_spec.rb:      Spree::MailMethod.create!(
spec/models/spree/order_spec.rb:        Spree::MailMethod.create!(
epic

Most helpful comment

All 8 comments

Can this be closed now that the PR is merged @sauloperez ?

@daniellemoorhead no, this issue is in place of the code that was removed in the PR. This issue is blocked until we reach Spree 2.0.

Moved to a Trello card for future reference: https://trello.com/c/cSVtpsns/14-remove-references-to-mailmethod

Bingo! there's a migration removing the spree_mail_methods table in https://github.com/spree/spree/commit/fbb95af890, which gets added by the version v2.0.5. Let's wait until then.

I see the table is only dropped on 2.0.5. But mail_method model is not in our 2-0-4 branch.
This means we can implement this now, right?

Meanwhile MailMethod call was moved inside CreateMailMethod service class and then the call was moved out of tasks/dev.rake to db/seeds, where it is today.

Apart from this point, all other work is represented in the issues of this epic. So, Ive created #2586 for this db/seeds.rb change.

The other references I find to MailMethod today on ofn-2.0-stable are the same on the code:

  • db/seeds.rb - this is now in the new issue #2586
  • app/services/create_mail_method.rb - this work is in #2164
  • app/mailers/spree/base_mailer_decorator.rb - this work is in #2198

But there a few more specs referencing it (this work is in #2020):
spec/controllers/admin/subscriptions_controller_spec.rb
spec/controllers/spree/admin/orders_controller_spec.rb
spec/controllers/spree/orders_controller_spec.rb
spec/controllers/user_passwords_controller_spec.rb
spec/features/consumer/shopping/orders_spec.rb
spec/jobs/subscription_confirm_job_spec.rb
spec/mailers/enterprise_mailer_spec.rb
spec/mailers/producer_mailer_spec.rb
spec/mailers/user_mailer_spec.rb
spec/models/order_cycle_spec.rb
spec/models/spree/order_spec.rb
spec/services/create_mail_method_spec.rb

As far as I can see "git grep MailMethod" is empty. Closing epic!

Was this page helpful?
0 / 5 - 0 ratings