diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-18 00:10:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-18 00:10:36 +0000 |
commit | 4eee0fe3f55ecdd5d607202d93508259239b590f (patch) | |
tree | 87bfbb30e6e98ae4135221d562515888e919ec10 /db/fixtures | |
parent | 0ad8135c1feeefa23ec883e409fb65b8b52882a1 (diff) | |
download | gitlab-ce-4eee0fe3f55ecdd5d607202d93508259239b590f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/development/36_achievements.rb | 44 | ||||
-rw-r--r-- | db/fixtures/development/heart.png | bin | 0 -> 22484 bytes | |||
-rw-r--r-- | db/fixtures/development/rocket.jpg | bin | 0 -> 28042 bytes |
3 files changed, 32 insertions, 12 deletions
diff --git a/db/fixtures/development/36_achievements.rb b/db/fixtures/development/36_achievements.rb index bde854f34b3..9bb485afe38 100644 --- a/db/fixtures/development/36_achievements.rb +++ b/db/fixtures/development/36_achievements.rb @@ -6,22 +6,15 @@ class Gitlab::Seeder::Achievements def initialize(group, user_ids) @group = group @maintainer_ids = group.members.maintainers.pluck(:user_id) + @maintainer_ids << User.admins.first.id @user_ids = user_ids end def seed! - achievement_ids = [] + achievement_ids = Achievements::Achievement.pluck(:id) + achievement_ids = seed_achievements if achievement_ids.empty? - ['revoked', 'first mr', 'hero', 'legend'].each do |achievement_name| - achievement_ids << ::Achievements::Achievement.create!( - namespace_id: group.id, - name: achievement_name - ).id - - print '.' - end - - user_ids.each_with_index do |user_id, user_index| + user_ids.reverse.each_with_index do |user_id, user_index| (user_index + 1).times do |achievement_index| ::Achievements::UserAchievement.create!( user_id: user_id, @@ -35,13 +28,40 @@ class Gitlab::Seeder::Achievements end end end + + def seed_achievements + achievement_ids = [] + + + ['revoked', 'first mr', 'hero', 'legend'].each do |achievement_name| + achievement_ids << ::Achievements::Achievement.create!( + namespace_id: group.id, + name: achievement_name, + description: achievement_name == 'hero' ? 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.' : nil, + avatar: seed_avatar(achievement_name) + ).id + + print '.' + end + + achievement_ids + end + + def seed_avatar(achievement_name) + case achievement_name + when 'first mr' + File.new(Rails.root.join('db', 'fixtures', 'development', 'rocket.jpg'), 'r') + when 'hero' + File.new(Rails.root.join('db', 'fixtures', 'development', 'heart.png'), 'r') + end + end end Gitlab::Seeder.quiet do puts "\nGenerating ahievements" group = Group.first - users = User.last(4).pluck(:id) + users = User.first(4).pluck(:id) Gitlab::Seeder::Achievements.new(group, users).seed! rescue => e warn "\nError seeding achievements: #{e}" diff --git a/db/fixtures/development/heart.png b/db/fixtures/development/heart.png Binary files differnew file mode 100644 index 00000000000..23ad1c76ffa --- /dev/null +++ b/db/fixtures/development/heart.png diff --git a/db/fixtures/development/rocket.jpg b/db/fixtures/development/rocket.jpg Binary files differnew file mode 100644 index 00000000000..ab843fe057c --- /dev/null +++ b/db/fixtures/development/rocket.jpg |