Sha256: 68a7d81142ead38125fd2796841c10ef807c1fe946ece581cc75ed316fb310cd

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

RSpec.describe Europeana::FeedbackButton::FeedbackController do
  def main_app
    Rails.application.class.routes.url_helpers
  end

  routes { Europeana::FeedbackButton::Engine.routes }

  describe 'POST create' do
    let(:params) { { locale: 'en', type: 'comment', text: 'This is good, five words!', url: main_app.root_path(locale: 'en'), format: :json } }
    subject { post :create, params }

    context 'with recipient configured' do
      before do
        Rails.application.config.x.feedback_mail_to = 'feedback@example.com'
      end

      it "should queue an email job" do
        expect { subject }.to change(ActionMailer::Base.deliveries, :length)
      end
      #it '' do
      #  message_delivery = instance_double(ActionMailer::MessageDelivery)
      #  expect(ServiceMailer).to receive(:new_user).with(@user).and_return(message_delivery)
      #  expect(message_delivery).to receive(:deliver_later)
      #  subject
        #expect { subject }.to change { Delayed::Job.where("handler LIKE '%FeedbackMailer%'").count }.by(1)
      #end
    end

    context 'without recipient configured' do
      before do
        Rails.application.config.x.feedback_mail_to = nil
      end

      it 'should not queue an email job' do
        expect { subject }.to_not change(ActionMailer::Base.deliveries, :length)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
europeana-feedback-button-0.0.4 spec/controllers/feedback_controller_spec.rb
europeana-feedback-button-0.0.3 spec/controllers/feedback_controller_spec.rb
europeana-feedback-button-0.0.2 spec/controllers/feedback_controller_spec.rb