diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-06-14 15:31:20 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-06-16 14:49:09 +0300 |
commit | 73bf9413b95d20860c09b3b37737c37add2d1342 (patch) | |
tree | 7444d5245c383e639974a22d0282a7255f694f49 /spec/models/project_feature_spec.rb | |
parent | d29347220c07ab0191cf208d3775475c7b5d71ca (diff) |
Refactor Project.with_feature_available_for_user
This method used to use a UNION, which would lead to it performing the
same query twice; producing less than ideal performance. Further, in
certain cases ActiveRecord could get confused and mess up the variable
bindings, though it's not clear how/why exactly this happens.
Fortunately we can work around all of this by building some of the WHERE
conditions manually, allowing us to use a simple OR statement to get all
the data we want without any of the above problems.
Diffstat (limited to 'spec/models/project_feature_spec.rb')
-rw-r--r-- | spec/models/project_feature_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 09a4448d387..580c83c12c0 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -4,6 +4,18 @@ describe ProjectFeature do let(:project) { create(:empty_project) } let(:user) { create(:user) } + describe '.quoted_access_level_column' do + it 'returns the table name and quoted column name for a feature' do + expected = if Gitlab::Database.postgresql? + '"project_features"."issues_access_level"' + else + '`project_features`.`issues_access_level`' + end + + expect(described_class.quoted_access_level_column(:issues)).to eq(expected) + end + end + describe '#feature_available?' do let(:features) { %w(issues wiki builds merge_requests snippets repository) } |