Skip to content

Commit

Permalink
Fix notification creation rake task for development
Browse files Browse the repository at this point in the history
- Fixes the following:

  * When the admin home project does not exist, calling the
    'create_and_assign_project' with 'admin.home_project' fails
    since it is nil.
  * The 'create_and_assign_project' returned the relationship,
    not the project
  • Loading branch information
krauselukas committed May 5, 2020
1 parent 9a58f24 commit 1d1d922
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/lib/tasks/dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace :dev do
User.session = requestor

# Projects
admin_home_project = admin.home_project || create_and_assign_project(admin.home_project, admin)
admin_home_project = admin.home_project || create_and_assign_project(admin.home_project_name, admin)
requestor_project = Project.find_by(name: 'requestor_project') || create_and_assign_project('requestor_project', requestor)

repetitions.times do |repetition|
Expand Down Expand Up @@ -416,8 +416,9 @@ def request_for_staging(staging_project, maintainer_project, suffix)
end

def create_and_assign_project(project_name, user)
create(:project, name: project_name)
create(:relationship, project: project_name, user: user, role: Role.hashed['maintainer'])
create(:project, name: project_name).tap do |project|
create(:relationship, project: project, user: user, role: Role.hashed['maintainer'])
end
end

def subscribe_to_all_notifications(user)
Expand Down

0 comments on commit 1d1d922

Please sign in to comment.