BigW Consortium Gitlab

invites_controller_spec.rb 871 Bytes
Newer Older
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
require 'spec_helper'

describe InvitesController do
  let(:token) { '123456' }
  let(:user) { create(:user) }
  let(:member) { create(:project_member, invite_token: token, invite_email: 'test@abc.com', user: user) }

  before do
    controller.instance_variable_set(:@member, member)
    sign_in(user)
  end

  describe 'GET #accept' do
    it 'accepts user' do
      get :accept, id: token
      member.reload

      expect(response.status).to eq(302)
      expect(member.user).to eq(user)
      expect(flash[:notice]).to include 'You have been granted'
    end
  end

  describe 'GET #decline' do
    it 'declines user' do
      get :decline, id: token
      expect{member.reload}.to raise_error ActiveRecord::RecordNotFound

      expect(response.status).to eq(302)
      expect(flash[:notice]).to include 'You have declined the invitation to join'
    end
  end
end