2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-20 07:28:28 +00:00
|
|
|
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
|
2018-12-17 22:52:17 +00:00
|
|
|
get :accept, params: { id: token }
|
2015-10-20 07:28:28 +00:00
|
|
|
member.reload
|
|
|
|
|
2020-01-27 12:08:35 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2015-10-20 07:28:28 +00:00
|
|
|
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
|
2018-12-17 22:52:17 +00:00
|
|
|
get :decline, params: { id: token }
|
2017-08-09 09:52:22 +00:00
|
|
|
expect {member.reload}.to raise_error ActiveRecord::RecordNotFound
|
2015-10-20 07:28:28 +00:00
|
|
|
|
2020-01-27 12:08:35 +00:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2015-10-20 07:28:28 +00:00
|
|
|
expect(flash[:notice]).to include 'You have declined the invitation to join'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|