diff options
author | James Ramsay <jramsay@gitlab.com> | 2018-08-02 22:39:46 +0300 |
---|---|---|
committer | James Ramsay <jramsay@gitlab.com> | 2018-08-03 18:55:21 +0300 |
commit | 79d90cb6bd99b7af572c65af89597c2e55217aea (patch) | |
tree | d28302d2bd63504b46c4eeef2877b4a3d099f893 /app | |
parent | c60cb3935089eeb358b8e96e63d879d5b49a3dcf (diff) |
Use Projects::UpdateService to archive projects
System hooks were not being triggered when projects were archived or
unarchived. Reuse the Projects::UpdateService to automatically
trigger system hooks and increase code reuse.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects_controller.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 8 |
2 files changed, 2 insertions, 10 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9d1c44db137..4d7e33d7b11 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -148,7 +148,7 @@ class ProjectsController < Projects::ApplicationController def archive return access_denied! unless can?(current_user, :archive_project, @project) - @project.archive! + ::Projects::UpdateService.new(@project, current_user, archived: true).execute respond_to do |format| format.html { redirect_to project_path(@project) } @@ -158,7 +158,7 @@ class ProjectsController < Projects::ApplicationController def unarchive return access_denied! unless can?(current_user, :archive_project, @project) - @project.unarchive! + ::Projects::UpdateService.new(@project, current_user, archived: false).execute respond_to do |format| format.html { redirect_to project_path(@project) } diff --git a/app/models/project.rb b/app/models/project.rb index 16d63639141..cf6160d9f64 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1320,14 +1320,6 @@ class Project < ActiveRecord::Base :visibility_level end - def archive! - update_attribute(:archived, true) - end - - def unarchive! - update_attribute(:archived, false) - end - def change_head(branch) if repository.branch_exists?(branch) repository.before_change_head |