diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 41c3a9002..61506421b 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -8,9 +8,11 @@ class Users::RegistrationsController < Devise::RegistrationsController # end # POST /resource - # def create - # super - # end + def create + retour = super + WelcomeMailer.welcome_email(User.last).deliver_now! + retour + end # GET /resource/edit # def edit diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index a60400215..7537fa606 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -26,6 +26,8 @@ -# -#<% end %> += devise_error_messages! + #form_login = image_tag('logo-tps.png') %br diff --git a/config/environments/test.rb b/config/environments/test.rb index 7cf15ecdc..addde8b69 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -37,7 +37,7 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - config.action_mailer.delivery_method = :mailjet + config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { :host => 'localhost:3000' } # Raises error for missing translations diff --git a/db/schema.rb b/db/schema.rb index d274fbcb2..89e2bc79f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -63,8 +63,8 @@ ActiveRecord::Schema.define(version: 20151214133426) do t.boolean "autorisation_donnees" t.string "nom_projet" t.integer "procedure_id" - t.datetime "created_at", default: '2015-12-07 09:51:46' - t.datetime "updated_at", default: '2015-12-07 09:51:46' + t.datetime "created_at", default: '2015-12-07 09:51:23' + t.datetime "updated_at", default: '2015-12-07 09:51:23' t.string "state" t.integer "user_id" t.text "json_latlngs" diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb new file mode 100644 index 000000000..fe1f70b5d --- /dev/null +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Users::RegistrationsController, type: :controller do + + let(:email) { 'test@octo.com' } + let(:password) { 'password' } + + let(:user) { { email: email, password: password, password_confirmation: password } } + + before do + @request.env["devise.mapping"] = Devise.mappings[:user] + end + + describe '.create' do + subject { post :create, user: user } + + it { expect(described_class).to be < Devise::RegistrationsController } + + it 'welcome email is send' do + expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer) + expect(WelcomeMailer).to receive(:deliver_now!) + + subject + end + end +end