Commit 90db83a7 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '299719-fj-fix-bug-personal-snippet-thread-discussion' into 'master'

Fix bug in personal snippet thread discussions

See merge request gitlab-org/gitlab!52490
parents 7beba17d 2950dd1a
...@@ -23,7 +23,7 @@ class Snippets::NotesController < ApplicationController ...@@ -23,7 +23,7 @@ class Snippets::NotesController < ApplicationController
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def snippet def snippet
PersonalSnippet.find_by(id: params[:snippet_id]) @snippet ||= PersonalSnippet.find_by(id: params[:snippet_id])
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
alias_method :noteable, :snippet alias_method :noteable, :snippet
......
---
title: Fix bug in personal snippet thread discussions
merge_request: 52490
author:
type: fixed
...@@ -4,15 +4,34 @@ require 'spec_helper' ...@@ -4,15 +4,34 @@ require 'spec_helper'
RSpec.describe 'Thread Comments Snippet', :js do RSpec.describe 'Thread Comments Snippet', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:snippet) { create(:project_snippet, :private, :repository, project: project, author: user) }
before do before do
project.add_maintainer(user)
sign_in(user) sign_in(user)
end
context 'with project snippets' do
let_it_be(:project) do
create(:project).tap do |p|
p.add_maintainer(user)
end
end
let_it_be(:snippet) { create(:project_snippet, :private, :repository, project: project, author: user) }
before do
visit project_snippet_path(project, snippet)
end
visit project_snippet_path(project, snippet) it_behaves_like 'thread comments', 'snippet'
end end
it_behaves_like 'thread comments', 'snippet' context 'with personal snippets' do
let_it_be(:snippet) { create(:personal_snippet, :private, :repository, author: user) }
before do
visit snippet_path(snippet)
end
it_behaves_like 'thread comments', 'snippet'
end
end end
...@@ -150,12 +150,13 @@ RSpec.shared_examples 'thread comments' do |resource_name| ...@@ -150,12 +150,13 @@ RSpec.shared_examples 'thread comments' do |resource_name|
wait_for_requests wait_for_requests
end end
it 'clicking "Start thread" will post a thread' do it 'clicking "Start thread" will post a thread and show a reply component' do
expect(page).to have_content(comment) expect(page).to have_content(comment)
new_comment = all(comments_selector).last new_comment = all(comments_selector).last
expect(new_comment).to have_selector('.discussion') expect(new_comment).to have_selector('.discussion')
expect(new_comment).to have_css('.discussion-with-resolve-btn')
end end
if resource_name =~ /(issue|merge request)/ if resource_name =~ /(issue|merge request)/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment