2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe InvitesController do
|
2015-10-24 18:46:33 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
get :accept, params: { id: token }
|
2015-10-24 18:46:33 +05:30
|
|
|
member.reload
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2015-10-24 18:46:33 +05:30
|
|
|
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
|
2019-02-15 15:39:39 +05:30
|
|
|
get :decline, params: { id: token }
|
2018-03-17 18:26:18 +05:30
|
|
|
expect {member.reload}.to raise_error ActiveRecord::RecordNotFound
|
2015-10-24 18:46:33 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2015-10-24 18:46:33 +05:30
|
|
|
expect(flash[:notice]).to include 'You have declined the invitation to join'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|