diff options
Diffstat (limited to 'spec/models/deploy_keys_project_spec.rb')
-rw-r--r-- | spec/models/deploy_keys_project_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb index ccc2c64e02c..7dd4d3129de 100644 --- a/spec/models/deploy_keys_project_spec.rb +++ b/spec/models/deploy_keys_project_spec.rb @@ -13,6 +13,21 @@ RSpec.describe DeployKeysProject do it { is_expected.to validate_presence_of(:deploy_key) } end + describe '.with_deploy_keys' do + subject(:scoped_query) { described_class.with_deploy_keys.last } + + it 'includes deploy_keys in query' do + project = create(:project) + create(:deploy_keys_project, project: project, deploy_key: create(:deploy_key)) + + includes_query_count = ActiveRecord::QueryRecorder.new { scoped_query }.count + deploy_key_query_count = ActiveRecord::QueryRecorder.new { scoped_query.deploy_key }.count + + expect(includes_query_count).to eq(2) + expect(deploy_key_query_count).to eq(0) + end + end + describe "Destroying" do let(:project) { create(:project) } subject { create(:deploy_keys_project, project: project) } |