diff --git a/Guardfile b/Guardfile index 94504338..78613f05 100644 --- a/Guardfile +++ b/Guardfile @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'active_support/inflector' + # Defines the matching rules for Guard. guard :minitest, spring: 'bin/rails test', all_on_start: false do # rubocop:disable Metrics/BlockLength watch(%r{^test/(.*)/?(.*)_test\.rb$}) @@ -9,9 +11,21 @@ guard :minitest, spring: 'bin/rails test', all_on_start: false do # rubocop:disa watch(%r{^app/models/(.*?)\.rb$}) do |matches| "test/models/#{matches[1]}_test.rb" end + watch(%r{^test/fixtures/(.*?)\.yml$}) do |matches| + "test/models/#{matches[1].singularize}_test.rb" + end watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches| resource_tests(matches[1]) end + watch(%r{^app/mailers/(.*?)\.rb$}) do |matches| + "test/mailers/#{matches[1]}_test.rb" + end + watch(%r{^test/fixtures/(.*)/(.*?)\.(html|text)$}) do |matches| + "test/mailers/#{matches[1]}_test.rb" + end + watch(%r{^lib/tasks/(.*?)\.rake$}) do |matches| + "test/tasks/#{matches[1]}_test.rb" + end watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches| ["test/controllers/#{matches[1]}_controller_test.rb"] + integration_tests(matches[1]) @@ -29,14 +43,8 @@ guard :minitest, spring: 'bin/rails test', all_on_start: false do # rubocop:disa ['test/controllers/sessions_controller_test.rb', 'test/integration/users_login_test.rb'] end - watch('app/controllers/account_activations_controller.rb') do - 'test/integration/users_signup_test.rb' - end - watch(%r{app/views/users/*}) do - resource_tests('users') + - ['test/integration/microposts_interface_test.rb'] - end end + # Returns the integration tests corresponding to the given resource. def integration_tests(resource = :all) if resource == :all diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index d84cb6e7..d9caa60e 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' + default from: 'no-reply@rezoleo.fr' layout 'mailer' end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 00000000..e4971b42 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class UserMailer < ApplicationMailer + default from: email_address_with_name('no-reply@rezoleo.fr', 'Lea5') + + def internet_expiration_7_days + @user = params[:user] + mail(to: email_address_with_name(@user.email, "#{@user.firstname} #{@user.lastname}"), + subject: 'Your internet will expire in 7 days') + end + + def internet_expiration_1_day + @user = params[:user] + mail(to: email_address_with_name(@user.email, "#{@user.firstname} #{@user.lastname}"), + subject: 'Your internet will expire tomorrow') + end +end diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index cbd34d2e..dfa86453 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -1,13 +1,13 @@ -
- - - + + - - <%= yield %> - + +<%= yield %> +