summaryrefslogtreecommitdiff
path: root/spec/controllers/admin/plan_limits_controller_spec.rb
blob: 2666925c2b7d4e43b1b8c18c6db41a5811e86f58 (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
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Admin::PlanLimitsController do
  let_it_be(:plan) { create(:plan) }
  let_it_be(:plan_limits) { create(:plan_limits, plan: plan) }

  describe 'POST create' do
    let(:params) do
      {
        plan_limits: {
          plan_id: plan.id,
          conan_max_file_size: file_size, id: plan_limits.id
        }
      }
    end

    context 'with an authenticated admin user' do
      let(:file_size) { 10.megabytes }

      it 'updates the plan limits', :aggregate_failures do
        sign_in(create(:admin))

        post :create, params: params

        expect(response).to redirect_to(general_admin_application_settings_path)
        expect(plan_limits.reload.conan_max_file_size).to eq(file_size)
      end
    end

    context 'without admin access' do
      let(:file_size) { 1.megabytes }

      it 'returns `not_found`' do
        sign_in(create(:user))

        post :create, params: params

        expect(response).to have_gitlab_http_status(:not_found)
        expect(plan_limits.conan_max_file_size).not_to eq(file_size)
      end
    end
  end
end