settings_spec.rb 1.2 KB
Newer Older
1 2 3 4 5 6 7 8
require 'spec_helper'

describe API::API, 'Settings', api: true  do
  include ApiHelpers

  let(:user) { create(:user) }
  let(:admin) { create(:admin) }

9 10 11
  describe "GET /application/settings" do
    it "should return application settings" do
      get api("/application/settings", admin)
Z
Z.J. van de Weg 已提交
12
      expect(response).to have_http_status(200)
13 14 15
      expect(json_response).to be_an Hash
      expect(json_response['default_projects_limit']).to eq(42)
      expect(json_response['signin_enabled']).to be_truthy
16
      expect(json_response['repository_storage']).to eq('default')
17
    end
18 19
  end

20
  describe "PUT /application/settings" do
21 22 23 24 25
    before do
      storages = { 'custom' => 'tmp/tests/custom_repositories' }
      allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
    end

26 27
    it "should update application settings" do
      put api("/application/settings", admin),
28
        default_projects_limit: 3, signin_enabled: false, repository_storage: 'custom'
Z
Z.J. van de Weg 已提交
29
      expect(response).to have_http_status(200)
30 31
      expect(json_response['default_projects_limit']).to eq(3)
      expect(json_response['signin_enabled']).to be_falsey
32
      expect(json_response['repository_storage']).to eq('custom')
33
    end
34 35
  end
end