Commit ba6c3ac8 authored by Victor Zagorodny's avatar Victor Zagorodny
Browse files

Fix ::User.group_view_details scope NULL handing

parent 3bc7333b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
    job_artifact_registry
    vulnerability_feedback
    vulnerabilities_feedback
    group_view
  )
  inflect.acronym 'EE'
end
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ module User
      # User's Group preference
      # Note: When adding an option, it's value MUST equal to the last value + 1.
      enum group_view: { details: 1, security_dashboard: 2 }, _prefix: true
      scope :group_view_details, -> { where('group_view = ? OR group_view IS NULL', group_view[:details]) }
    end

    class_methods do
+6 −1
Original line number Diff line number Diff line
@@ -4,9 +4,10 @@

describe Gitlab::UsageData do
  before do
    projects.last.creator.block
    projects.last.creator.block # to get at least one non-active User
  end

  # using Array.new to create a different creator User for each of the projects
  let(:projects) { Array.new(3) { create(:project, creator: create(:user, group_view: :security_dashboard)) } }
  let!(:board) { create(:board, project: projects[0]) }

@@ -28,6 +29,10 @@
      create(:package, project: projects[1])

      create(:project_tracing_setting, project: projects[0])

      # for group_view testing
      create(:user) # user with group_view = NULL (should be counted as having default value 'details')
      create(:user, group_view: :details)
    end

    subject { described_class.data }