주의 사항(Gotchas)
GitLab CE 및 EE 개발 중 기여자가 알아야 할 잠재적인 함정과 주의 사항을 설명합니다.
이 가이드의 목적은 GitLab CE 및 EE 개발 중 기여자가 마주치거나 피해야 할 잠재적인 "gotcha"(함정)를 문서화하는 것입니다. app/assets 디렉터리에서 파일을 읽지 마세요 # Omnibus GitLab은 에셋 컴파일 후 app/assets 디렉터리를 삭제 했습니다. ee/app/assets , vendor/assets 디렉터리도 함께 삭제됩니다. 즉, Omnibus로 설치된 GitLab 인스턴스에서 해당 디렉터리의 파일을 읽으면 실패합니다: file = Rails.root.join('app/assets/images/logo.svg') # This file does not exist, read will fail with: # Errno::ENOENT: No such file or directory @ rb_sysopen File.read(file) 시퀀스로 생성된 속성의 절댓값에 대해 단언하지 마세요 # 다음 factory를 고려해 보세요: FactoryBot.define do factory :label do sequence(:title) { |n| "label#{n}" } end end 다음 API spec을 고려해 보세요: require 'spec_helper' RSpec.describe API::Labels do it 'creates a first label' do create(:label) get api("/projects/#{project.id}/labels", user) expect(response).to have_gitlab_http_status(:ok) expect(json_response.first['name']).to eq('label1') end it 'creates a second label' do create(:label) get api("/projects/#{project.id}/labels", user) expect(response).to have_gitlab_http_status(:ok) expect(json_response.first['name']).to eq('label1') end end 실행하면 이 spec은 우리가 기대하는 대로 동작하지 않습니다: 1) API::API reproduce sequence issue creates a second label Failure/Error: expect(json_response.first['name']).to eq('label1') expected: "label1" got: "label2" (compared using ==) 이는 FactoryBot 시퀀스가 각 예제마다 초기화되지 않기 때문입니다. 시퀀스로 생성된 값은 factory 사용 시 유일성 제약이 있는 속성을 명시적으로 설정하지 않아도 되도록 하기 위해서만 존재한다는 점을 기억하세요. 해결 방법 # 시퀀스로 생성된 속성의 값에 대해 단언해야 한다면, 해당 값을 명시적으로 설정해야 합니다. 또한 설정하는 값이 시퀀스 패턴과 일치해서는 안 됩니다. 예를 들어, :label factory