debian-mirror-gitlab/spec/controllers/projects/group_links_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.4 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Projects::GroupLinksController do
2021-01-03 14:25:43 +05:30
let_it_be(:group) { create(:group, :private) }
let_it_be(:group2) { create(:group, :private) }
let_it_be(:project) { create(:project, :private, group: group2) }
let_it_be(:user) { create(:user) }
2016-06-02 11:05:42 +05:30
before do
2021-04-29 21:17:54 +05:30
travel_to DateTime.new(2019, 4, 1)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2016-06-02 11:05:42 +05:30
sign_in(user)
end
2021-04-29 21:17:54 +05:30
after do
travel_back
end
2021-01-03 14:25:43 +05:30
describe '#update' do
let_it_be(:link) do
create(
:project_group_link,
{
project: project,
group: group
}
)
end
let(:expiry_date) { 1.month.from_now.to_date }
before do
travel_to Time.now.utc.beginning_of_day
put(
:update,
params: {
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: link.id,
group_link: { group_access: Gitlab::Access::GUEST, expires_at: expiry_date }
},
format: :json
)
end
context 'when `expires_at` is set' do
it 'returns correct json response' do
2022-04-04 11:22:00 +05:30
expect(json_response).to eq({ "expires_in" => controller.helpers.time_ago_with_tooltip(expiry_date), "expires_soon" => false })
2021-01-03 14:25:43 +05:30
end
end
context 'when `expires_at` is not set' do
let(:expiry_date) { nil }
it 'returns empty json response' do
expect(json_response).to be_empty
end
end
end
2016-06-02 11:05:42 +05:30
end