diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-03-21 19:11:24 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-03-21 19:11:24 -0300 |
commit | 8d544645f0ef114586212835cf011a3e268c9ec1 (patch) | |
tree | 4ffb1d46f923bfe2f25b194f9ad0411b3a5e008e /db/migrate | |
parent | 261569b2466e455ff308cc54fb1db51bc8dc2880 (diff) | |
download | gitlab-ce-8d544645f0ef114586212835cf011a3e268c9ec1.tar.gz |
Add specs and add visibility level to admin groups
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20160301124843_add_visibility_level_to_groups.rb | 8 | ||||
-rw-r--r-- | db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb | 22 |
2 files changed, 7 insertions, 23 deletions
diff --git a/db/migrate/20160301124843_add_visibility_level_to_groups.rb b/db/migrate/20160301124843_add_visibility_level_to_groups.rb index cef553981e7..89b5ac19983 100644 --- a/db/migrate/20160301124843_add_visibility_level_to_groups.rb +++ b/db/migrate/20160301124843_add_visibility_level_to_groups.rb @@ -1,6 +1,12 @@ class AddVisibilityLevelToGroups < ActiveRecord::Migration def change #All groups public by default - add_column :namespaces, :visibility_level, :integer, null: false, default: 20 + add_column :namespaces, :visibility_level, :integer, null: false, default: allowed_visibility_level + end + + def allowed_visibility_level + # TODO: Don't use `current_application_settings` + allowed_levels = Gitlab::VisibilityLevel.values - current_application_settings.restricted_visibility_levels + allowed_levels.max end end diff --git a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb b/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb deleted file mode 100644 index 62d96907c8f..00000000000 --- a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb +++ /dev/null @@ -1,22 +0,0 @@ -#Create visibility level field on DB -#Sets default_visibility_level to value on settings if not restricted -#If value is restricted takes higher visibility level allowed - -class AddDefaultGroupVisibilityToApplicationSettings < ActiveRecord::Migration - def up - add_column :application_settings, :default_group_visibility, :integer - execute("UPDATE application_settings SET default_group_visibility = #{allowed_visibility_level}") - end - - def down - remove_column :application_settings, :default_group_visibility - end - - private - - def allowed_visibility_level - # TODO: Don't use `current_application_settings` - allowed_levels = Gitlab::VisibilityLevel.values - current_application_settings.restricted_visibility_levels - allowed_levels.max - end -end |