Sha256: d19ff1c996e522ab0b2a2bb9a278cd6e215dc4f74c51e9f7d7895d86b0db534b

Contents?: true

Size: 1.33 KB

Versions: 22

Compression:

Stored size: 1.33 KB

Contents

describe Spotlight::ContactForm do
  subject { described_class.new(name: 'Root', email: 'user@example.com').tap { |c| c.current_exhibit = exhibit } }
  let(:exhibit) { FactoryGirl.create(:exhibit) }

  context 'with a site-wide contact email' do
    before { allow(Spotlight::Engine.config).to receive_messages default_contact_email: 'root@localhost' }

    it 'sends the email to the configured contact' do
      expect(subject.headers[:to]).to eq Spotlight::Engine.config.default_contact_email
    end

    context 'with exhibit-specific contacts' do
      before { exhibit.contact_emails.create(email: 'curator@example.com', confirmed_at: Time.zone.now) }

      it 'appends exhibit-specific contacts as cc recipients' do
        expect(subject.headers[:cc]).to eq 'curator@example.com'
      end
    end
  end

  context 'with exhibit-specific contacts' do
    before { exhibit.contact_emails.create(email: 'curator@example.com', confirmed_at: Time.zone.now) }
    before { exhibit.contact_emails.create(email: 'addl_curator@example.com', confirmed_at: Time.zone.now) }

    it 'sends the email to the first contact' do
      expect(subject.headers[:to]).to eq 'curator@example.com'
    end

    it 'appends exhibit-specific contacts as cc recipients' do
      expect(subject.headers[:cc]).to eq 'curator@example.com, addl_curator@example.com'
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-0.30.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.29.1 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.29.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.28.3 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.28.2 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.28.1 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.28.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.27.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.26.1 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.26.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.25.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.24.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.23.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.22.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.21.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.20.3 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.20.2 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.20.1 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.20.0 spec/models/spotlight/contact_form_spec.rb
blacklight-spotlight-0.19.2 spec/models/spotlight/contact_form_spec.rb