summaryrefslogtreecommitdiff
path: root/spec/controllers/unsubscribes_controller_spec.rb
blob: ea9fe79a25f721777d56c045ce9556e01b4cb34a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'spec_helper'

describe UnsubscribesController do
  let!(:user) { create :user, email: 'me@example.com' }

  describe "show" do
    it "responds with success" do
      get :show, email:  Base64.urlsafe_encode64('me@example.com')

      assert_response :success
    end

    it "behaves the same if email address isn't known in the system" do
      get :show, email: Base64.urlsafe_encode64('i@dont_exists.com')

      assert_response :success
    end
  end

  describe "create" do
    it "unsubscribes the connected user" do
      post :create, email: Base64.urlsafe_encode64('me@example.com')

      assert user.reload.admin_email_unsubscribed_at
    end

    # Don't tell if the email does not exists
    it "behaves the same if email address isn't known in the system" do
      post :create, email: Base64.urlsafe_encode64('i@dont_exists.com')

      assert_response :redirect
    end
  end
end