Sha256: 3ee6eab73ead59fd7af6d14c92b08f949a51eef5f2016158a45441ffc246d4e0

Contents?: true

Size: 1.71 KB

Versions: 23

Compression:

Stored size: 1.71 KB

Contents

require 'rails_helper'

describe MessageTrain::UnsubscribesController do
  include_context 'loaded site'
  include ControllerMacros
  routes { MessageTrain::Engine.routes }

  let(:valid_attributes) {
    { from_type: 'Group', from_id: membered_group.id }
  }

  let(:invalid_attributes) {
    { from_type: 'Group', from_id: empty_group.id }
  }

  before do
    login_user first_user
  end

  describe "GET #index" do
    before do
      get :index
    end
    it_should_behave_like 'a successful page', which_renders: 'index'

    context 'loads subscriptions into @subscriptions' do
      subject { assigns(:subscriptions) }
      it { should be_an Array }
      it { should have_at_least(3).items }
    end
  end

  describe "POST #create" do
    describe 'with invalid attributes' do
      before do
        post :create, unsubscribe: invalid_attributes
      end
      it_should_behave_like 'a 404 Not Found error'
    end
    describe 'with valid attributes' do
      before do
        post :create, unsubscribe: valid_attributes
      end
      it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are now unsubscribed from Membered Group, which means that you will not be notified by email of any messages received by that Group.'
      it_should_behave_like 'a response without error'
    end
  end

  describe "DELETE #destroy" do
    before do
      delete :destroy, id: first_user.unsubscribes.where(from_type: 'Group', from_id: unsubscribed_group.id).first.id
    end
    it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are no longer unsubscribed from Unsubscribed Group, which means that you will now be notified by email of any messages received in that Group.'
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
message_train-0.5.0 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.6 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.5 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.4 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.3 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.2 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.1 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.4.0 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.3.1 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.3.0 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.12 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.11 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.10 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.9 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.8 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.7 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.6 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.5 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.4 spec/controllers/message_train/unsubscribes_controller_spec.rb
message_train-0.2.3 spec/controllers/message_train/unsubscribes_controller_spec.rb