mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge remote-tracking branch 'origin/master' into single-order-patches
This commit is contained in:
@@ -8,6 +8,8 @@ class Enterprise < ActiveRecord::Base
|
||||
preference :shopfront_taxon_order, :string, default: ""
|
||||
|
||||
devise :confirmable, reconfirmable: true, confirmation_keys: [ :id, :email ]
|
||||
handle_asynchronously :send_confirmation_instructions
|
||||
handle_asynchronously :send_on_create_confirmation_instructions
|
||||
|
||||
self.inheritance_column = nil
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Spree.user_class.class_eval do
|
||||
handle_asynchronously :send_reset_password_instructions
|
||||
|
||||
has_many :enterprise_roles, :dependent => :destroy
|
||||
has_many :enterprises, through: :enterprise_roles
|
||||
has_many :owned_enterprises, class_name: 'Enterprise', foreign_key: :owner_id, inverse_of: :owner
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
SECRET_TOKEN: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
TIMEZONE: Melbourne
|
||||
# Default country for dropdowns etc.
|
||||
DEFAULT_COUNTRY: Australia
|
||||
# Default country for dropdowns etc. See for codes: http://en.wikipedia.org/wiki/ISO_3166-1
|
||||
DEFAULT_COUNTRY_CODE: AU
|
||||
# Locale for translation.
|
||||
LOCALE: en
|
||||
# Spree zone.
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'delayed_job.log'))
|
||||
Delayed::Worker.destroy_failed_jobs = false
|
||||
Delayed::Worker.max_run_time = 15.minutes
|
||||
|
||||
# Notify bugsnag when a job fails
|
||||
# Code adapted from http://trevorturk.com/2011/01/25/notify-hoptoad-if-theres-an-exception-in-delayedjob/
|
||||
class Delayed::Worker
|
||||
alias_method :original_handle_failed_job, :handle_failed_job
|
||||
|
||||
def handle_failed_job(job, error)
|
||||
Bugsnag.notify(error)
|
||||
original_handle_failed_job(job, error)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ Spree.config do |config|
|
||||
config.checkout_zone = ENV["CHECKOUT_ZONE"]
|
||||
config.currency = ENV['CURRENCY']
|
||||
if Spree::Country.table_exists?
|
||||
country = Spree::Country.find_by_name(ENV["DEFAULT_COUNTRY"])
|
||||
country = Spree::Country.find_by_iso(ENV['DEFAULT_COUNTRY_CODE'])
|
||||
config.default_country_id = country.id if country.present?
|
||||
else
|
||||
config.default_country_id = 12 # Australia
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddAddressInstancesToExistingEnterpriseGroups < ActiveRecord::Migration
|
||||
def change
|
||||
country = Spree::Country.find_by_name(ENV['DEFAULT_COUNTRY'])
|
||||
country = Spree::Country.find_by_iso(ENV['DEFAULT_COUNTRY_CODE'])
|
||||
state = country.states.first
|
||||
EnterpriseGroup.all.each do |g|
|
||||
next if g.address.present?
|
||||
|
||||
@@ -16,4 +16,4 @@ echo "--- Loading test database"
|
||||
bundle exec rake db:test:load
|
||||
|
||||
echo "--- Running tests"
|
||||
bundle exec rspec spec --format progress
|
||||
bundle exec rspec spec
|
||||
|
||||
@@ -32,7 +32,10 @@ describe UserPasswordsController do
|
||||
end
|
||||
|
||||
it "renders Darkswarm" do
|
||||
clear_jobs
|
||||
user.send_reset_password_instructions
|
||||
flush_jobs # Send the reset password instructions
|
||||
user.reload
|
||||
spree_get :edit, reset_password_token: user.reset_password_token
|
||||
response.should render_template "user_passwords/edit"
|
||||
end
|
||||
|
||||
@@ -81,9 +81,11 @@ feature "Authentication", js: true do
|
||||
|
||||
scenario "resetting password" do
|
||||
fill_in "Your email", with: user.email
|
||||
click_reset_password_button
|
||||
page.should have_reset_password
|
||||
ActionMailer::Base.deliveries.last.subject.should =~ /Password Reset/
|
||||
expect do
|
||||
click_reset_password_button
|
||||
page.should have_reset_password
|
||||
end.to enqueue_job Delayed::PerformableMethod
|
||||
Delayed::Job.last.payload_object.method_name.should == :send_reset_password_instructions_without_delay
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,10 +10,10 @@ describe Enterprise do
|
||||
|
||||
context "when the email address has not already been confirmed" do
|
||||
it "sends a confirmation email" do
|
||||
mail_message = double "Mail::Message"
|
||||
expect(EnterpriseMailer).to receive(:confirmation_instructions).and_return mail_message
|
||||
mail_message.should_receive :deliver
|
||||
create(:enterprise, owner: user, email: "unknown@email.com", confirmed_at: nil )
|
||||
expect do
|
||||
create(:enterprise, owner: user, email: "unknown@email.com", confirmed_at: nil )
|
||||
end.to enqueue_job Delayed::PerformableMethod
|
||||
Delayed::Job.last.payload_object.method_name.should == :send_on_create_confirmation_instructions_without_delay
|
||||
end
|
||||
|
||||
it "does not send a welcome email" do
|
||||
@@ -41,10 +41,10 @@ describe Enterprise do
|
||||
let!(:enterprise) { create(:enterprise, owner: user) }
|
||||
|
||||
it "when the email address has not already been confirmed" do
|
||||
mail_message = double "Mail::Message"
|
||||
expect(EnterpriseMailer).to receive(:confirmation_instructions).and_return mail_message
|
||||
mail_message.should_receive :deliver
|
||||
enterprise.update_attributes(email: "unknown@email.com")
|
||||
expect do
|
||||
enterprise.update_attributes(email: "unknown@email.com")
|
||||
end.to enqueue_job Delayed::PerformableMethod
|
||||
Delayed::Job.last.payload_object.method_name.should == :send_confirmation_instructions_without_delay
|
||||
end
|
||||
|
||||
it "when the email address has already been confirmed" do
|
||||
|
||||
Reference in New Issue
Block a user