Sha256: 52d586bb28983d6ddd9f02ce6c73f3803007e17a991da1bdc943938d49a69441

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

describe MailboxController, type: :controller do
  let(:mock_box) { {} }

  before do
    allow_any_instance_of(described_class).to receive(:authenticate_user!).and_return(true)
    allow(UserMailbox).to receive(:new).and_return(mock_box)
  end

  describe "#index" do
    it "shows message" do
      expect(mock_box).to receive(:inbox).and_return(["test"])
      get :index
      expect(response).to be_success
      expect(assigns[:messages]).to eq(["test"])
    end
  end

  describe "#delete_all" do
    it "deletes all messages" do
      expect(mock_box).to receive(:delete_all)
      get :delete_all
    end
  end

  describe "#delete" do
    it "deletes message" do
      expect(mock_box).to receive(:destroy).with("4")
      delete :destroy, id: "4"
      expect(response).to redirect_to(@routes.url_helpers.notifications_path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-7.0.0.beta3 spec/controllers/mailbox_controller_spec.rb
sufia-7.0.0.beta2 spec/controllers/mailbox_controller_spec.rb
sufia-7.0.0.beta1 spec/controllers/mailbox_controller_spec.rb