Commit 4b71ef59 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian Committed by Rémy Coutable

Optimize factory creation in user view issues spec

parent b86db507
...@@ -3,12 +3,16 @@ ...@@ -3,12 +3,16 @@
require "spec_helper" require "spec_helper"
RSpec.describe "User views issue" do RSpec.describe "User views issue" do
let(:project) { create(:project_empty_repo, :public) } let_it_be(:project) { create(:project_empty_repo, :public) }
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:issue) { create(:issue, project: project, description: "# Description header", author: user) } let_it_be(:issue) { create(:issue, project: project, description: "# Description header", author: user) }
let_it_be(:note) { create(:note, noteable: issue, project: project, author: user) }
before do before_all do
project.add_developer(user) project.add_developer(user)
end
before do
sign_in(user) sign_in(user)
visit(project_issue_path(project, issue)) visit(project_issue_path(project, issue))
...@@ -37,24 +41,20 @@ RSpec.describe "User views issue" do ...@@ -37,24 +41,20 @@ RSpec.describe "User views issue" do
context 'when showing status of the author of the issue' do context 'when showing status of the author of the issue' do
it_behaves_like 'showing user status' do it_behaves_like 'showing user status' do
let(:user_with_status) { issue.author } let(:user_with_status) { user }
end end
end end
context 'when showing status of a user who commented on an issue', :js do context 'when showing status of a user who commented on an issue', :js do
let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) }
it_behaves_like 'showing user status' do it_behaves_like 'showing user status' do
let(:user_with_status) { create(:user) } let(:user_with_status) { user }
end end
end end
context 'when status message has an emoji', :js do context 'when status message has an emoji', :js do
let(:message) { 'My status with an emoji' } let_it_be(:message) { 'My status with an emoji' }
let(:message_emoji) { 'basketball' } let_it_be(:message_emoji) { 'basketball' }
let_it_be(:status) { create(:user_status, user: user, emoji: 'smirk', message: "#{message} :#{message_emoji}:") }
let!(:note) { create(:note, noteable: issue, project: project, author: user) }
let!(:status) { create(:user_status, user: user, emoji: 'smirk', message: "#{message} :#{message_emoji}:") }
it 'correctly renders the emoji' do it 'correctly renders the emoji' do
tooltip_span = page.first(".user-status-emoji[title^='#{message}']") tooltip_span = page.first(".user-status-emoji[title^='#{message}']")
......
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