Sha256: 2c8256378378694dd4522efad78fd95a74cb0690cb606155cfdce220e72615a8

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require 'rails_helper'

describe 'Eventos' do
  let(:user) { create :user, :developer }

  before do
    create :user # no dev
    sign_in user
    SimpleUserNotifier.with(message: 'New post').deliver(User.all, enqueue_job: false)
  end

  it 'renders the event index' do
    get '/a/eventos'

    expect(response.body).to include 'New post'
  end

  describe 'posting events' do
    subject do
      get '/a/eventos/new'
      expect(response.body).to include 'Tooltip'
      post '/a/eventos', params: {
        evento: {
          type: 'SimpleUserNotifier',
          message: 'hola',
          target:
        }
      }
    end

    context 'cuando se manda a los devs' do
      let(:target) { 'devs' }

      it do
        expect { subject }.to change(Noticed::Notification, :count).by(1)
      end
    end

    context 'cuando se manda a todos' do
      let(:target) { 'todos' }

      it do
        expect { subject }.to change(Noticed::Notification, :count).by(2)
      end
    end

    context 'cuando hay error' do
      let(:target) { 'bla' }

      it do
        subject
        expect(response).to have_http_status(:unprocessable_entity)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.108 pg_engine/spec/requests/admin/eventos_spec.rb
pg_rails-7.0.8.pre.alpha.107 pg_engine/spec/requests/admin/eventos_spec.rb
pg_rails-7.0.8.pre.alpha.106 pg_engine/spec/requests/admin/eventos_spec.rb
pg_rails-7.0.8.pre.alpha.105 pg_engine/spec/requests/admin/eventos_spec.rb
pg_rails-7.0.8.pre.alpha.104 pg_engine/spec/requests/admin/eventos_spec.rb