Commit Graph

11 Commits

Author SHA1 Message Date
GitLab Bot 0d6fa03312 Add latest changes from gitlab-org/gitlab@master 2020-02-06 18:08:54 +00:00
Nick Thomas 013f7cd24c
Inherit from ApplicationRecord instead of ActiveRecord::Base 2019-03-28 16:18:23 +00:00
Yorick Peterse 590ff80f83
Refactor how a few ActiveRecord enums are defined
In a few models we define ActiveRecord enums that are redefined in EE
using the following pattern:

    enum :some_enum, {
      ...
    }.merge(EE_ENUM_VALUES)

This particular approach is problematic to deal with, because it
requires that we `prepend` and EE module _before_ defining the enum.
This typically translates to the `prepend` being the first line in the
model in EE, but this can easily lead to merge conflicts when developers
add more `include` and/or `prepend` lines.

As part of https://gitlab.com/gitlab-org/gitlab-ee/issues/8244 and
https://gitlab.com/gitlab-org/gitlab-ee/issues/8241 we are moving
`prepend` to the last line in a file, reducing the chances of running
into merge conflicts. This poses a bit of a problem with the pattern
above, because this pattern does not allow us to move the `prepend`
further down a file.

To resolve this problem, we simply move the Hash value of the enum to a
separate class method. This method is defined in a separate module where
necessary, allowing us to use it like so:

    enum :failure_reasons, ::SomeModelEnums.failure_reasons

The method in turn is defined in a very straightforward manner:

    module SomeModelEnums
      def self.failure_reasons
        {
          ...
        }
      end
    end

This makes it easy for EE to add values without requiring the `prepend`
to be placed before the `enum` is defined.

For more information, see the following issues and merge requests:

* https://gitlab.com/gitlab-org/gitlab-ee/issues/8244
* https://gitlab.com/gitlab-org/gitlab-ee/issues/8241
* https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8424
2018-11-15 17:41:54 +01:00
Luke Bennett 06c24d497d Revert "Merge branch 'ce-6983-promote-starting-a-gitlab-com-trial' into 'master'"
This reverts merge request !21551
2018-10-12 09:45:50 +00:00
Luke Bennett 8c4399e530
Lint 2018-09-24 11:43:20 +01:00
Luke Bennett 693e435f2f
port EE 2018-09-06 05:13:44 +01:00
gfyoung 50abbd3e53 Enable frozen string in app/models/*.rb
Partially addresses #47424.
2018-07-26 16:55:41 -07:00
Dennis Tang a9496c27c9 Resolve "Inform users of up to $500 offer for GCP account" 2018-05-07 18:06:02 +00:00
Matija Čupić c1e1f8070b
Bump UserCallout feature_name enum index 2018-02-05 14:26:01 +01:00
Matija Čupić 20714ee902
Change UserCallout feautre_name to enum 2018-02-03 00:18:25 +01:00
Matija Čupić 648826721f
Rename Callout to UserCallout 2018-02-02 22:51:03 +01:00