You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cartodb/spec/mailers/user_mailer_spec.rb

80 lines
2.2 KiB

6 years ago
require 'spec_helper_min'
describe UserMailer do
include_context 'organization with users helper'
6 years ago
before(:all) do
@carto_org_user_1.password_reset_token = 'token'
@carto_org_user_1.save
end
after(:each) do
ActionMailer::Base.deliveries = []
end
6 years ago
describe ".password_reset" do
before(:each) do
@mailer = UserMailer.password_reset(@carto_org_user_1)
end
6 years ago
it "delivers the mail" do
expect { @mailer.deliver_now }.to change(ActionMailer::Base.deliveries, :size).by(1)
6 years ago
end
it "delivers with the expected subject" do
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eql('Reset CARTO password')
end
it "delivers to the expected recipients" do
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.to).to eql([@carto_org_user_1.email])
6 years ago
end
it "delivers a link with the password reset token" do
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.body).to include('/password_resets/token/edit')
6 years ago
end
end
6 years ago
describe ".share_visualization" do
before(:each) do
@kuviz = FactoryGirl.create(:kuviz_visualization, user: @carto_org_user_2)
@mailer = UserMailer.share_visualization(@kuviz, @carto_org_user_1)
6 years ago
end
it "delivers the mail" do
expect { @mailer.deliver_now }.to change(ActionMailer::Base.deliveries, :size).by(1)
end
it "delivers with the expected subject" do
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.subject).to eql("#{@carto_org_user_2.username} has shared a CARTO map with you")
6 years ago
end
it "delivers to the expected recipients" do
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
expect(mail.to).to eql([@carto_org_user_1.email])
6 years ago
end
it "delivers a link with the right link for kuviz" do
6 years ago
@mailer.deliver_now
mail = ActionMailer::Base.deliveries.first
base_url = "http://#{@organization.name}.localhost.lan:53716"
expected_link = "#{base_url}/u/#{@carto_org_user_2.username}/kuviz/#{@kuviz.id}"
expect(mail.body).to include(expected_link)
6 years ago
end
end
end