OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
legacy_spec to spec
ulferts1f18dfca1a65
diff --git a/app/mailers/base_mailer.rb b/app/mailers/base_mailer.rbindex a6401d2b310..b5997912e05 100644--- a/app/mailers/base_mailer.rb+++ b/app/mailers/base_mailer.rb@@ -97,7 +97,7 @@ class BaseMailer < ActionMailer::Basedef default_url_optionsoptions = super.merge host: host, protocol: protocol- unless OpenProject::Configuration.rails_relative_url_root.blank?+ if OpenProject::Configuration.rails_relative_url_root.present?options[:script_name] = OpenProject::Configuration.rails_relative_url_rootenddiff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rbindex db109663a96..eabe9df73a2 100644--- a/spec/mailers/user_mailer_spec.rb+++ b/spec/mailers/user_mailer_spec.rb@@ -63,6 +63,8 @@ describe UserMailer, type: :mailer doshared_examples_for 'mail is sent' dolet(:letters_sent_count) { 1 }+ let(:mail) { deliveries.first }+ let(:html_body) { mail.body.parts.detect { |p| p.content_type.include? 'text/html' }.body.encoded }it 'actually sends a mail' doexpect(deliveries.size).to eql(letters_sent_count)@@ -257,7 +259,7 @@ describe UserMailer, type: :mailer doendit 'includes a link to the message' do- expect(deliveries.first.body.encoded)+ expect(html_body).to have_link(message.subject,href: topic_url(message, host: Setting.host_name, r: message.id, anchor: "message-#{message.id}"))end@@ -266,6 +268,95 @@ describe UserMailer, type: :mailer doit_behaves_like 'does only send mails to author if permitted'end+ describe '#account_information' do+ let(:pwd) { "pAsswORd" }++ before do+ UserMailer.account_information(recipient, pwd).deliver_now+ end++ it_behaves_like 'mail is sent' do+ it 'includes the password' do+ expect(html_body)+ .to have_content(pwd)+ end+ end++ it_behaves_like 'does only send mails to author if permitted'+ end++ describe '#news_added' do+ let(:news) { FactoryBot.build_stubbed(:news) }++ before do+ UserMailer.news_added(recipient, news, user).deliver_now+ end++ it_behaves_like 'mail is sent' do+ it 'carries a message_id' do+ expect(mail.message_id)+ .to eql(UserMailer.generate_message_id(news, recipient))+ end+ end++ it_behaves_like 'does only send mails to author if permitted'+ end++ describe '#news_comment_added' do+ let(:news) { FactoryBot.build_stubbed(:news) }+ let(:comment) { FactoryBot.build_stubbed(:comment, commented: news) }++ before do+ UserMailer.news_comment_added(recipient, comment, user).deliver_now+ end++ it_behaves_like 'mail is sent'++ it_behaves_like 'does only send mails to author if permitted'+ end++ describe '#password_lost' do+ let(:token) { FactoryBot.build_stubbed(:recovery_token) }+ let(:recipient) { token.user }++ before do+ UserMailer.password_lost(token).deliver_now+ end++ it_behaves_like 'mail is sent' do+ it 'includes a link to reset' do+ url = account_lost_password_url(host: Setting.host_name, token: token.value)++ expect(html_body)+ .to have_link(url,+ href: url)+ end+ end++ it_behaves_like 'does only send mails to author if permitted'+ end++ describe '#user_signed_up' do+ let(:token) { FactoryBot.build_stubbed(:invitation_token) }+ let(:recipient) { token.user }++ before do+ UserMailer.user_signed_up(token).deliver_now+ end++ it_behaves_like 'mail is sent' do+ it 'includes a link to activate' do+ url = account_activate_url(host: Setting.host_name, token: token.value)++ expect(html_body)+ .to have_link(url,+ href: url)+ end+ end++ it_behaves_like 'does only send mails to author if permitted'+ end+describe '#message_id' dodescribe 'same user' dolet(:journal_2) { FactoryBot.build_stubbed(:work_package_journal) }diff --git a/spec_legacy/functional/user_mailer_spec.rb b/spec_legacy/functional/user_mailer_spec.rbindex 8962f61f197..d1c4d662149 100644--- a/spec_legacy/functional/user_mailer_spec.rb+++ b/spec_legacy/functional/user_mailer_spec.rb@@ -143,41 +143,6 @@ describe UserMailer, type: :mailer doassert mail.encoded.include?('href')end- it 'should not send email without recipient' do- user = FactoryBot.create(:user)- news = FactoryBot.create(:news)-- # notify him- user.pref[:no_self_notified] = false- user.pref.save- ActionMailer::Base.deliveries.clear- UserMailer.news_added(user, news, user).deliver_now- assert_equal 1, last_email.to.size-- # nobody to notify- user.pref[:no_self_notified] = true- user.pref.save- ActionMailer::Base.deliveries.clear- UserMailer.news_added(user, news, user).deliver_now- assert ActionMailer::Base.deliveries.empty?- end-- it 'should reply posted message id' do- user = FactoryBot.create(:user, preferences: { no_self_notified: false })- parent = FactoryBot.create(:message)- message = FactoryBot.create(:message, parent: parent)- UserMailer.message_posted(user, message, user).deliver_now- mail = ActionMailer::Base.deliveries.last- refute_nil mail- assert_equal UserMailer.generate_message_id(message, user), mail.message_id- assert_match mail.references, UserMailer.generate_message_id(parent, user)- assert_select_email do- # link to the reply- assert_select 'a[href=?]',- "#{Setting.protocol}://#{Setting.host_name}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", text: message.subject- end- end-context '#issue_add',with_settings: { available_languages: ['en', 'de'], default_language: 'de' } doit 'should change mail language depending on recipient language' do@@ -212,48 +177,6 @@ describe UserMailer, type: :mailer doendend- it 'should news added' do- user = FactoryBot.create(:user)- news = FactoryBot.create(:news)- assert UserMailer.news_added(user, news, user).deliver_now- end-- it 'should news comment added' do- user = FactoryBot.create(:user)- news = FactoryBot.create(:news)- comment = FactoryBot.create(:comment, commented: news)- assert UserMailer.news_comment_added(user, comment, user).deliver_now- end-- it 'should message posted' do- user = FactoryBot.create(:user)- message = FactoryBot.create(:message)- assert UserMailer.message_posted(user, message, user).deliver_now- end-- it 'should account information' do- user = FactoryBot.create(:user)- assert UserMailer.account_information(user, 'pAsswORd').deliver_now- end-- it 'should lost password' do- user = FactoryBot.create(:user)- token = FactoryBot.create(:recovery_token, user: user)- assert UserMailer.password_lost(token).deliver_now- end-- it 'should register' do- user = FactoryBot.create(:user)- token = FactoryBot.create(:invitation_token, user: user)- Setting.host_name = 'redmine.foo'- Setting.protocol = 'https'-- mail = UserMailer.user_signed_up(token)- assert mail.deliver_now- assert mail.body.parts[0].body.include?("https://redmine.foo/account/activate?token=#{token.value}")- assert mail.body.parts[1].body.include?("https://redmine.foo/account/activate?token=#{token.value}")- end-context 'with locale settings',with_settings: { available_languages: ['en', 'de'], default_language: 'de' } doit 'should mailer should not change locale' do