summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2017-03-15 15:26:43 +0100
committerAdam Niedzielski <adamsunday@gmail.com>2017-03-15 15:26:43 +0100
commit08c92ebf9eb7230d75fb087cedd819665904161b (patch)
treedacd0da37d20d95d495f3814b2651914ffa32e49
parent2eefc8f56b544af6de4af34b3af8de8996479549 (diff)
downloadgitlab-ce-issue-title-vue-adam-2.tar.gz
Add backend changesissue-title-vue-adam-2
-rw-r--r--app/controllers/projects/issues_controller.rb17
-rw-r--r--app/models/issue.rb11
-rw-r--r--lib/gitlab/etag_caching/middleware.rb3
3 files changed, 14 insertions, 17 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 8eaa064db38..cfd2c46fbd8 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -192,22 +192,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def rendered_title
- digest = hexdigest(@issue.title)
- response = if digest == params.fetch(:digest)
- { changed: false }
- else
- {
- changed: true,
- digest: digest,
- title: view_context.markdown_field(@issue, :title)
- }
- end
-
- respond_to do |format|
- format.json do
- render json: response
- end
- end
+ render json: { title: view_context.markdown_field(@issue, :title) }
end
protected
diff --git a/app/models/issue.rb b/app/models/issue.rb
index dba9398a43c..f188dcb673c 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -40,6 +40,8 @@ class Issue < ActiveRecord::Base
scope :include_associations, -> { includes(:assignee, :labels, project: :namespace) }
+ after_save :expire_etag_cache
+
attr_spammable :title, spam_title: true
attr_spammable :description, spam_description: true
@@ -243,4 +245,13 @@ class Issue < ActiveRecord::Base
def publicly_visible?
project.public? && !confidential?
end
+
+ def expire_etag_cache
+ key = Gitlab::Routing.url_helpers.rendered_title_namespace_project_issue_path(
+ project.namespace,
+ project,
+ self
+ )
+ Gitlab::EtagCaching::Store.new.touch(key)
+ end
end
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index ffbc6e17dc5..987b7288db8 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -3,7 +3,8 @@ module Gitlab
class Middleware
RESERVED_WORDS = ProjectPathValidator::RESERVED.map { |word| "/#{word}/" }.join('|')
ROUTE_REGEXP = Regexp.union(
- %r(^(?!.*(#{RESERVED_WORDS})).*/noteable/issue/\d+/notes\z)
+ %r(^(?!.*(#{RESERVED_WORDS})).*/noteable/issue/\d+/notes\z),
+ %r(/issues/\d+/rendered_title\z)
)
def initialize(app)