Commit 026e9885 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen

Even more hound fixes

Signed-off-by: default avatarJeroen van Baarsen <jeroenvanbaarsen@gmail.com>
parent 5bb743ef
...@@ -45,7 +45,7 @@ describe Projects::BlobController do ...@@ -45,7 +45,7 @@ describe Projects::BlobController do
context 'redirect to tree' do context 'redirect to tree' do
let(:id) { 'markdown/doc' } let(:id) { 'markdown/doc' }
it "redirects" do it 'redirects' do
expect(subject). expect(subject).
to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
end end
......
...@@ -31,8 +31,8 @@ describe Projects::CommitController do ...@@ -31,8 +31,8 @@ describe Projects::CommitController do
end end
it "should not escape Html" do it "should not escape Html" do
allow_any_instance_of(Commit).to receive(:"to_#{format}") allow_any_instance_of(Commit).to receive(:"to_#{format}").
.and_return('HTML entities &<>" ') and_return('HTML entities &<>" ')
get :show, project_id: project.to_param, id: commit.id, format: format get :show, project_id: project.to_param, id: commit.id, format: format
......
...@@ -12,9 +12,9 @@ describe Import::GithubController do ...@@ -12,9 +12,9 @@ describe Import::GithubController do
token = "asdasd12345" token = "asdasd12345"
allow_any_instance_of(Gitlab::GithubImport::Client). allow_any_instance_of(Gitlab::GithubImport::Client).
to receive(:get_token).and_return(token) to receive(:get_token).and_return(token)
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", Gitlab.config.omniauth.providers << OpenStruct.new(app_id: 'asd123',
app_secret: "asd123", app_secret: 'asd123',
name: "github") name: 'github')
get :callback get :callback
......
...@@ -50,7 +50,11 @@ describe Projects::TreeController do ...@@ -50,7 +50,11 @@ describe Projects::TreeController do
context 'redirect to blob' do context 'redirect to blob' do
let(:id) { 'master/README.md' } let(:id) { 'master/README.md' }
it { is_expected.to redirect_to("/#{project.path_with_namespace}/blob/master/README.md") } it 'redirects' do
redirect_url = "/#{project.path_with_namespace}/blob/master/README.md"
expect(subject).
to redirect_to(redirect_url)
end
end end
end end
end end
...@@ -33,15 +33,17 @@ describe "Admin::Users", feature: true do ...@@ -33,15 +33,17 @@ describe "Admin::Users", feature: true do
it "should apply defaults to user" do it "should apply defaults to user" do
click_button "Create user" click_button "Create user"
user = User.find_by(username: 'bang') user = User.find_by(username: 'bang')
expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit) expect(user.projects_limit).
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group) to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group).
to eq(Gitlab.config.gitlab.default_can_create_group)
end end
it "should create user with valid data" do it "should create user with valid data" do
click_button "Create user" click_button "Create user"
user = User.find_by(username: 'bang') user = User.find_by(username: 'bang')
expect(user.name).to eq("Big Bang") expect(user.name).to eq('Big Bang')
expect(user.email).to eq("bigbang@mail.com") expect(user.email).to eq('bigbang@mail.com')
end end
it "should call send mail" do it "should call send mail" do
...@@ -54,7 +56,7 @@ describe "Admin::Users", feature: true do ...@@ -54,7 +56,7 @@ describe "Admin::Users", feature: true do
click_button "Create user" click_button "Create user"
user = User.find_by(username: 'bang') user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
expect(email.subject).to have_content("Account was created") expect(email.subject).to have_content('Account was created')
expect(email.text_part.body).to have_content(user.email) expect(email.text_part.body).to have_content(user.email)
expect(email.text_part.body).to have_content('password') expect(email.text_part.body).to have_content('password')
end end
...@@ -80,8 +82,8 @@ describe "Admin::Users", feature: true do ...@@ -80,8 +82,8 @@ describe "Admin::Users", feature: true do
end end
it "should have user edit page" do it "should have user edit page" do
expect(page).to have_content("Name") expect(page).to have_content('Name')
expect(page).to have_content("Password") expect(page).to have_content('Password')
end end
describe "Update user" do describe "Update user" do
...@@ -93,13 +95,13 @@ describe "Admin::Users", feature: true do ...@@ -93,13 +95,13 @@ describe "Admin::Users", feature: true do
end end
it "should show page with new data" do it "should show page with new data" do
expect(page).to have_content("bigbang@mail.com") expect(page).to have_content('bigbang@mail.com')
expect(page).to have_content("Big Bang") expect(page).to have_content('Big Bang')
end end
it "should change user entry" do it "should change user entry" do
@simple_user.reload @simple_user.reload
expect(@simple_user.name).to eq("Big Bang") expect(@simple_user.name).to eq('Big Bang')
expect(@simple_user.is_admin?).to be_truthy expect(@simple_user.is_admin?).to be_truthy
end end
end end
......
...@@ -17,12 +17,13 @@ describe "Dashboard Issues Feed", feature: true do ...@@ -17,12 +17,13 @@ describe "Dashboard Issues Feed", feature: true do
it "should render atom feed via private token" do it "should render atom feed via private token" do
visit issues_dashboard_path(:atom, private_token: user.private_token) visit issues_dashboard_path(:atom, private_token: user.private_token)
expect(response_headers['Content-Type']).to have_content("application/atom+xml") expect(response_headers['Content-Type']).
expect(body).to have_selector("title", text: "#{user.name} issues") to have_content('application/atom+xml')
expect(body).to have_selector("author email", text: issue1.author_email) expect(body).to have_selector('title', text: "#{user.name} issues")
expect(body).to have_selector("entry summary", text: issue1.title) expect(body).to have_selector('author email', text: issue1.author_email)
expect(body).to have_selector("author email", text: issue2.author_email) expect(body).to have_selector('entry summary', text: issue1.title)
expect(body).to have_selector("entry summary", text: issue2.title) expect(body).to have_selector('author email', text: issue2.author_email)
expect(body).to have_selector('entry summary', text: issue2.title)
end end
end end
end end
......
...@@ -7,7 +7,7 @@ describe "Dashboard Feed", feature: true do ...@@ -7,7 +7,7 @@ describe "Dashboard Feed", feature: true do
context "projects atom feed via private token" do context "projects atom feed via private token" do
it "should render projects atom feed" do it "should render projects atom feed" do
visit dashboard_path(:atom, private_token: user.private_token) visit dashboard_path(:atom, private_token: user.private_token)
expect(body).to have_selector("feed title") expect(body).to have_selector('feed title')
end end
end end
...@@ -28,7 +28,8 @@ describe "Dashboard Feed", feature: true do ...@@ -28,7 +28,8 @@ describe "Dashboard Feed", feature: true do
end end
it "should have issue comment event" do it "should have issue comment event" do
expect(body).to have_content("#{user.name} commented on issue ##{issue.iid}") expect(body).
to have_content("#{user.name} commented on issue ##{issue.iid}")
end end
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe "Issues Feed", feature: true do describe 'Issues Feed', feature: true do
describe "GET /issues" do describe 'GET /issues' do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:project) { create(:project) } let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) } let!(:issue) { create(:issue, author: user, project: project) }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
context "when authenticated" do context 'when authenticated' do
it "should render atom feed" do it 'should render atom feed' do
login_with user login_with user
visit project_issues_path(project, :atom) visit project_issues_path(project, :atom)
expect(response_headers['Content-Type']).to have_content("application/atom+xml") expect(response_headers['Content-Type']).
expect(body).to have_selector("title", text: "#{project.name} issues") to have_content('application/atom+xml')
expect(body).to have_selector("author email", text: issue.author_email) expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector("entry summary", text: issue.title) expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
end end
end end
context "when authenticated via private token" do context 'when authenticated via private token' do
it "should render atom feed" do it 'should render atom feed' do
visit project_issues_path(project, :atom, private_token: user.private_token) visit project_issues_path(project, :atom,
private_token: user.private_token)
expect(response_headers['Content-Type']).to have_content("application/atom+xml") expect(response_headers['Content-Type']).
expect(body).to have_selector("title", text: "#{project.name} issues") to have_content('application/atom+xml')
expect(body).to have_selector("author email", text: issue.author_email) expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector("entry summary", text: issue.title) expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
end end
end end
end end
......
...@@ -4,17 +4,23 @@ describe "User Feed", feature: true do ...@@ -4,17 +4,23 @@ describe "User Feed", feature: true do
describe "GET /" do describe "GET /" do
let!(:user) { create(:user) } let!(:user) { create(:user) }
context "user atom feed via private token" do context 'user atom feed via private token' do
it "should render user atom feed" do it "should render user atom feed" do
visit user_path(user, :atom, private_token: user.private_token) visit user_path(user, :atom, private_token: user.private_token)
expect(body).to have_selector("feed title") expect(body).to have_selector('feed title')
end end
end end
context 'feed content' do context 'feed content' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issue) { create(:issue, project: project, author: user, description: '') } let(:issue) do
let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) } create(:issue, project: project,
author: user, description: '')
end
let(:note) do
create(:note, noteable: issue, author: user,
note: 'Bug confirmed', project: project)
end
before do before do
project.team << [user, :master] project.team << [user, :master]
...@@ -23,11 +29,11 @@ describe "User Feed", feature: true do ...@@ -23,11 +29,11 @@ describe "User Feed", feature: true do
visit user_path(user, :atom, private_token: user.private_token) visit user_path(user, :atom, private_token: user.private_token)
end end
it "should have issue opened event" do it 'should have issue opened event' do
expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}") expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
end end
it "should have issue comment event" do it 'should have issue comment event' do
expect(body). expect(body).
to have_content("#{safe_name} commented on issue ##{issue.iid}") to have_content("#{safe_name} commented on issue ##{issue.iid}")
end end
......
require 'spec_helper' require 'spec_helper'
describe "Issues", feature: true do describe 'Issues', feature: true do
include SortingHelper include SortingHelper
let(:project) { create(:project) } let(:project) { create(:project) }
...@@ -12,7 +12,7 @@ describe "Issues", feature: true do ...@@ -12,7 +12,7 @@ describe "Issues", feature: true do
project.team << [[@user, user2], :developer] project.team << [[@user, user2], :developer]
end end
describe "Edit issue" do describe 'Edit issue' do
let!(:issue) do let!(:issue) do
create(:issue, create(:issue,
author: @user, author: @user,
...@@ -25,30 +25,34 @@ describe "Issues", feature: true do ...@@ -25,30 +25,34 @@ describe "Issues", feature: true do
click_link "Edit" click_link "Edit"
end end
it "should open new issue popup" do it 'should open new issue popup' do
expect(page).to have_content("Issue ##{issue.iid}") expect(page).to have_content("Issue ##{issue.iid}")
end end
describe "fill in" do describe 'fill in' do
before do before do
fill_in "issue_title", with: "bug 345" fill_in 'issue_title', with: 'bug 345'
fill_in "issue_description", with: "bug description" fill_in 'issue_description', with: 'bug description'
end end
it { expect { click_button "Save changes" }.to_not change {Issue.count} } it 'does not change issue count' do
expect {
click_button 'Save changes'
}.to_not change { Issue.count }
end
it "should update issue fields" do it 'should update issue fields' do
click_button "Save changes" click_button 'Save changes'
expect(page).to have_content @user.name expect(page).to have_content @user.name
expect(page).to have_content "bug 345" expect(page).to have_content 'bug 345'
expect(page).to have_content project.name expect(page).to have_content project.name
end end
end end
end end
describe "Editing issue assignee" do describe 'Editing issue assignee' do
let!(:issue) do let!(:issue) do
create(:issue, create(:issue,
author: @user, author: @user,
...@@ -56,7 +60,7 @@ describe "Issues", feature: true do ...@@ -56,7 +60,7 @@ describe "Issues", feature: true do
project: project) project: project)
end end
it 'allows user to select unasigned', :js => true do it 'allows user to select unasigned', js: true do
visit edit_project_issue_path(project, issue) visit edit_project_issue_path(project, issue)
expect(page).to have_content "Assign to #{@user.name}" expect(page).to have_content "Assign to #{@user.name}"
...@@ -65,14 +69,14 @@ describe "Issues", feature: true do ...@@ -65,14 +69,14 @@ describe "Issues", feature: true do
sleep 2 # wait for ajax stuff to complete sleep 2 # wait for ajax stuff to complete
first('.user-result').click first('.user-result').click
click_button "Save changes" click_button 'Save changes'
expect(page).to have_content 'Assignee: none' expect(page).to have_content 'Assignee: none'
expect(issue.reload.assignee).to be_nil expect(issue.reload.assignee).to be_nil
end end
end end
describe "Filter issue" do describe 'Filter issue' do
before do before do
['foobar', 'barbaz', 'gitlab'].each do |title| ['foobar', 'barbaz', 'gitlab'].each do |title|
create(:issue, create(:issue,
...@@ -90,7 +94,7 @@ describe "Issues", feature: true do ...@@ -90,7 +94,7 @@ describe "Issues", feature: true do
let(:issue) { @issue } let(:issue) { @issue }
it "should allow filtering by issues with no specified milestone" do it 'should allow filtering by issues with no specified milestone' do
visit project_issues_path(project, milestone_id: '0') visit project_issues_path(project, milestone_id: '0')
expect(page).not_to have_content 'foobar' expect(page).not_to have_content 'foobar'
...@@ -98,7 +102,7 @@ describe "Issues", feature: true do ...@@ -98,7 +102,7 @@ describe "Issues", feature: true do
expect(page).to have_content 'gitlab' expect(page).to have_content 'gitlab'
end end
it "should allow filtering by a specified milestone" do it 'should allow filtering by a specified milestone' do
visit project_issues_path(project, milestone_id: issue.milestone.id) visit project_issues_path(project, milestone_id: issue.milestone.id)
expect(page).to have_content 'foobar' expect(page).to have_content 'foobar'
...@@ -106,7 +110,7 @@ describe "Issues", feature: true do ...@@ -106,7 +110,7 @@ describe "Issues", feature: true do
expect(page).not_to have_content 'gitlab' expect(page).not_to have_content 'gitlab'
end end
it "should allow filtering by issues with no specified assignee" do it 'should allow filtering by issues with no specified assignee' do
visit project_issues_path(project, assignee_id: '0') visit project_issues_path(project, assignee_id: '0')
expect(page).to have_content 'foobar' expect(page).to have_content 'foobar'
...@@ -114,7 +118,7 @@ describe "Issues", feature: true do ...@@ -114,7 +118,7 @@ describe "Issues", feature: true do
expect(page).not_to have_content 'gitlab' expect(page).not_to have_content 'gitlab'
end end
it "should allow filtering by a specified assignee" do it 'should allow filtering by a specified assignee' do
visit project_issues_path(project, assignee_id: @user.id) visit project_issues_path(project, assignee_id: @user.id)
expect(page).not_to have_content 'foobar' expect(page).not_to have_content 'foobar'
...@@ -126,7 +130,11 @@ describe "Issues", feature: true do ...@@ -126,7 +130,11 @@ describe "Issues", feature: true do
describe 'filter issue' do describe 'filter issue' do
titles = ['foo','bar','baz'] titles = ['foo','bar','baz']
titles.each_with_index do |title, index| titles.each_with_index do |title, index|
let!(title.to_sym) { create(:issue, title: title, project: project, created_at: Time.now - (index * 60)) } let!(title.to_sym) do
create(:issue, title: title,
project: project,
created_at: Time.now - (index * 60))
end
end end
let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') } let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') } let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
...@@ -134,15 +142,15 @@ describe "Issues", feature: true do ...@@ -134,15 +142,15 @@ describe "Issues", feature: true do
it 'sorts by newest' do it 'sorts by newest' do
visit project_issues_path(project, sort: sort_value_recently_created) visit project_issues_path(project, sort: sort_value_recently_created)
expect(first_issue).to include("foo") expect(first_issue).to include('foo')
expect(last_issue).to include("baz") expect(last_issue).to include('baz')
end end
it 'sorts by oldest' do it 'sorts by oldest' do
visit project_issues_path(project, sort: sort_value_oldest_created) visit project_issues_path(project, sort: sort_value_oldest_created)
expect(first_issue).to include("baz") expect(first_issue).to include('baz')
expect(last_issue).to include("foo") expect(last_issue).to include('foo')
end end
it 'sorts by most recently updated' do it 'sorts by most recently updated' do
...@@ -150,7 +158,7 @@ describe "Issues", feature: true do ...@@ -150,7 +158,7 @@ describe "Issues", feature: true do
baz.save baz.save
visit project_issues_path(project, sort: sort_value_recently_updated) visit project_issues_path(project, sort: sort_value_recently_updated)
expect(first_issue).to include("baz") expect(first_issue).to include('baz')
end end
it 'sorts by least recently updated' do it 'sorts by least recently updated' do
...@@ -158,7 +166,7 @@ describe "Issues", feature: true do ...@@ -158,7 +166,7 @@ describe "Issues", feature: true do
baz.save baz.save
visit project_issues_path(project, sort: sort_value_oldest_updated) visit project_issues_path(project, sort: sort_value_oldest_updated)
expect(first_issue).to include("baz") expect(first_issue).to include('baz')
end end
describe 'sorting by milestone' do describe 'sorting by milestone' do
...@@ -172,13 +180,13 @@ describe "Issues", feature: true do ...@@ -172,13 +180,13 @@ describe "Issues", feature: true do
it 'sorts by recently due milestone' do it 'sorts by recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_soon) visit project_issues_path(project, sort: sort_value_milestone_soon)
expect(first_issue).to include("foo") expect(first_issue).to include('foo')
end end
it 'sorts by least recently due milestone' do it 'sorts by least recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_later) visit project_issues_path(project, sort: sort_value_milestone_later)
expect(first_issue).to include("bar") expect(first_issue).to include('bar')
end end
end end
...@@ -193,10 +201,12 @@ describe "Issues", feature: true do ...@@ -193,10 +201,12 @@ describe "Issues", feature: true do
end end
it 'sorts with a filter applied' do it 'sorts with a filter applied' do
visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id) visit project_issues_path(project,
sort: sort_value_oldest_created,
assignee_id: user2.id)
expect(first_issue).to include("bar") expect(first_issue).to include('bar')
expect(last_issue).to include("foo") expect(last_issue).to include('foo')
expect(page).not_to have_content 'baz' expect(page).not_to have_content 'baz'
end end
end end
...@@ -210,11 +220,13 @@ describe "Issues", feature: true do ...@@ -210,11 +220,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do it 'with dropdown menu' do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
find('.edit-issue.inline-update #issue_assignee_id').set project.team.members.first.id find('.edit-issue.inline-update #issue_assignee_id').
set project.team.members.first.id
click_button 'Update Issue' click_button 'Update Issue'
expect(page).to have_content "Assignee:" expect(page).to have_content 'Assignee:'
has_select?('issue_assignee_id', :selected => project.team.members.first.name) has_select?('issue_assignee_id',
selected: project.team.members.first.name)
end end
end end
...@@ -228,7 +240,7 @@ describe "Issues", feature: true do ...@@ -228,7 +240,7 @@ describe "Issues", feature: true do
issue.save issue.save
end end
it "shows assignee text", js: true do it 'shows assignee text', js: true do
logout logout
login_with guest login_with guest
...@@ -247,12 +259,13 @@ describe "Issues", feature: true do ...@@ -247,12 +259,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do it 'with dropdown menu' do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id') find('.edit-issue.inline-update').
select(milestone.title, from: 'issue_milestone_id')
click_button 'Update Issue' click_button 'Update Issue'
expect(page).to have_content "Milestone changed to #{milestone.title}" expect(page).to have_content "Milestone changed to #{milestone.title}"
expect(page).to have_content "Milestone: #{milestone.title}" expect(page).to have_content "Milestone: #{milestone.title}"
has_select?('issue_assignee_id', :selected => milestone.title) has_select?('issue_assignee_id', selected: milestone.title)
end end
end end
...@@ -265,7 +278,7 @@ describe "Issues", feature: true do ...@@ -265,7 +278,7 @@ describe "Issues", feature: true do
issue.save issue.save
end end
it "shows milestone text", js: true do it 'shows milestone text', js: true do
logout logout
login_with guest login_with guest
...@@ -282,7 +295,7 @@ describe "Issues", feature: true do ...@@ -282,7 +295,7 @@ describe "Issues", feature: true do
issue.save issue.save
end end
it 'allows user to remove assignee', :js => true do it 'allows user to remove assignee', js: true do
visit project_issue_path(project, issue) visit project_issue_path(project, issue)
expect(page).to have_content "Assignee: #{user2.name}" expect(page).to have_content "Assignee: #{user2.name}"
...@@ -298,10 +311,10 @@ describe "Issues", feature: true do ...@@ -298,10 +311,10 @@ describe "Issues", feature: true do
end end
def first_issue def first_issue
all("ul.issues-list li").first.text all('ul.issues-list li').first.text
end end
def last_issue def last_issue
all("ul.issues-list li").last.text all('ul.issues-list li').last.text
end end
end end
...@@ -3,10 +3,12 @@ require 'spec_helper' ...@@ -3,10 +3,12 @@ require 'spec_helper'
describe 'Comments' do describe 'Comments' do
include RepoHelpers include RepoHelpers
describe "On a merge request", js: true, feature: true do describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) } let!(:merge_request) { create(:merge_request) }
let!(:project) { merge_request.source_project } let!(:project) { merge_request.source_project }
let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) } let!(:note) do
create(:note_on_merge_request, :with_attachment, project: project)
end
before do before do
login_as :admin login_as :admin
...@@ -15,19 +17,20 @@ describe 'Comments' do ...@@ -15,19 +17,20 @@ describe 'Comments' do
subject { page } subject { page }
describe "the note form" do describe 'the note form' do
it 'should be valid' do it 'should be valid' do
is_expected.to have_css(".js-main-target-form", visible: true, count: 1) is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
expect(find(".js-main-target-form input[type=submit]").value).to eq("Add Comment") expect(find('.js-main-target-form input[type=submit]').value).
to eq('Add Comment')
within('.js-main-target-form') do within('.js-main-target-form') do
expect(page).not_to have_link('Cancel') expect(page).not_to have_link('Cancel')
end end
end end
describe "with text" do describe 'with text' do
before do before do
within(".js-main-target-form") do within('.js-main-target-form') do
fill_in "note[note]", with: "This is awesome" fill_in 'note[note]', with: 'This is awesome'
end end
end end
...@@ -40,41 +43,45 @@ describe 'Comments' do ...@@ -40,41 +43,45 @@ describe 'Comments' do
end end
end end
describe "when posting a note" do describe 'when posting a note' do
before do before do
within(".js-main-target-form") do within('.js-main-target-form') do
fill_in "note[note]", with: "This is awsome!" fill_in 'note[note]', with: 'This is awsome!'
find('.js-md-preview-button').click find('.js-md-preview-button').click
click_button "Add Comment" click_button 'Add Comment'
end end
end end
it 'should be added and form reset' do it 'should be added and form reset' do
is_expected.to have_content("This is awsome!") is_expected.to have_content('This is awsome!')
within('.js-main-target-form') do within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!') expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).to have_css('.js-md-preview', visible: :hidden) expect(page).to have_css('.js-md-preview', visible: :hidden)
end end
within(".js-main-target-form") { is_expected.to have_css(".js-note-text", visible: true) } within('.js-main-target-form') do
is_expected.to have_css('.js-note-text', visible: true)
end
end end
end end
describe "when editing a note", js: true do describe 'when editing a note', js: true do
it "should contain the hidden edit form" do it 'should contain the hidden edit form' do
within("#note_#{note.id}") { is_expected.to have_css(".note-edit-form", visible: false) } within("#note_#{note.id}") do
is_expected.to have_css('.note-edit-form', visible: false)
end
end end
describe "editing the note" do describe 'editing the note' do
before do before do
find('.note').hover find('.note').hover
find(".js-note-edit").click find(".js-note-edit").click
end end
it "should show the note edit form and hide the note body" do it 'should show the note edit form and hide the note body' do
within("#note_#{note.id}") do within("#note_#{note.id}") do
expect(find(".current-note-edit-form", visible: true)).to be_visible expect(find('.current-note-edit-form', visible: true)).to be_visible
expect(find(".note-edit-form", visible: true)).to be_visible expect(find('.note-edit-form', visible: true)).to be_visible
expect(find(:css, ".note-text", visible: false)).not_to be_visible expect(find(:css, '.note-text', visible: false)).not_to be_visible
end end
end end
...@@ -87,41 +94,43 @@ describe 'Comments' do ...@@ -87,41 +94,43 @@ describe 'Comments' do
#end #end
#end #end
it "appends the edited at time to the note" do it 'appends the edited at time to the note' do
within(".current-note-edit-form") do within('.current-note-edit-form') do
fill_in "note[note]", with: "Some new content" fill_in 'note[note]', with: 'Some new content'
find(".btn-save").click find('.btn-save').click
end end
within("#note_#{note.id}") do within("#note_#{note.id}") do
is_expected.to have_css(".note_edited_ago") is_expected.to have_css('.note_edited_ago')
expect(find(".note_edited_ago").text).to match(/less than a minute ago/) expect(find('.note_edited_ago').text).
to match(/less than a minute ago/)
end end
end end
end end
describe "deleting an attachment" do describe 'deleting an attachment' do
before do before do
find('.note').hover find('.note').hover
find(".js-note-edit").click find('.js-note-edit').click
end end
it "shows the delete link" do it 'shows the delete link' do
within(".note-attachment") do within('.note-attachment') do
is_expected.to have_css(".js-note-attachment-delete") is_expected.to have_css('.js-note-attachment-delete')
end end
end end
it "removes the attachment div and resets the edit form" do it 'removes the attachment div and resets the edit form' do
find(".js-note-attachment-delete").click find('.js-note-attachment-delete').click
is_expected.not_to have_css(".note-attachment") is_expected.not_to have_css('.note-attachment')
expect(find(".current-note-edit-form", visible: false)).not_to be_visible expect(find('.current-note-edit-form', visible: false)).
not_to be_visible
end end
end end
end end
end end
describe "On a merge request diff", js: true, feature: true do describe 'On a merge request diff', js: true, feature: true do
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project } let(:project) { merge_request.source_project }
...@@ -132,68 +141,74 @@ describe 'Comments' do ...@@ -132,68 +141,74 @@ describe 'Comments' do
subject { page } subject { page }
describe "when adding a note" do describe 'when adding a note' do
before do before do
click_diff_line click_diff_line
end end
describe "the notes holder" do describe 'the notes holder' do
it { is_expected.to have_css(".js-temp-notes-holder") } it { is_expected.to have_css('.js-temp-notes-holder') }
it { within(".js-temp-notes-holder") { is_expected.to have_css(".new_note") } } it 'has .new_note css class' do
within('.js-temp-notes-holder') do
expect(subject).to have_css('.new_note')
end
end
end end
describe "the note form" do describe 'the note form' do
it "shouldn't add a second form for same row" do it "shouldn't add a second form for same row" do
click_diff_line click_diff_line
is_expected.to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1) is_expected.
to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form",
count: 1)
end end
it "should be removed when canceled" do it 'should be removed when canceled' do
within(".diff-file form[rel$='#{line_code}']") do within(".diff-file form[rel$='#{line_code}']") do
find(".js-close-discussion-note-form").trigger("click") find('.js-close-discussion-note-form').trigger('click')
end end
is_expected.to have_no_css(".js-temp-notes-holder") is_expected.to have_no_css('.js-temp-notes-holder')
end end
end end
end end
describe "with muliple note forms" do describe 'with muliple note forms' do
before do before do
click_diff_line click_diff_line
click_diff_line(line_code_2) click_diff_line(line_code_2)
end end
it { is_expected.to have_css(".js-temp-notes-holder", count: 2) } it { is_expected.to have_css('.js-temp-notes-holder', count: 2) }
describe "previewing them separately" do describe 'previewing them separately' do
before do before do
# add two separate texts and trigger previews on both # add two separate texts and trigger previews on both
within("tr[id='#{line_code}'] + .js-temp-notes-holder") do within("tr[id='#{line_code}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 7" fill_in 'note[note]', with: 'One comment on line 7'
find('.js-md-preview-button').click find('.js-md-preview-button').click
end end
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10" fill_in 'note[note]', with: 'Another comment on line 10'
find('.js-md-preview-button').click find('.js-md-preview-button').click
end end
end end
end end
describe "posting a note" do describe 'posting a note' do
before do before do
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10" fill_in 'note[note]', with: 'Another comment on line 10'
click_button("Add Comment") click_button('Add Comment')
end end
end end
it 'should be added as discussion' do it 'should be added as discussion' do
is_expected.to have_content("Another comment on line 10") is_expected.to have_content('Another comment on line 10')
is_expected.to have_css(".notes_holder") is_expected.to have_css('.notes_holder')
is_expected.to have_css(".notes_holder .note", count: 1) is_expected.to have_css('.notes_holder .note', count: 1)
is_expected.to have_button('Reply') is_expected.to have_button('Reply')
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe "Profile account page", feature: true do describe 'Profile account page', feature: true do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
login_as :user login_as :user
end end
describe "when signup is enabled" do describe 'when signup is enabled' do
before do before do
ApplicationSetting.any_instance.stub(signup_enabled?: true) ApplicationSetting.any_instance.stub(signup_enabled?: true)
visit profile_account_path visit profile_account_path
end end
it { expect(page).to have_content("Remove account") } it { expect(page).to have_content('Remove account') }
it "should delete the account" do it 'should delete the account' do
expect { click_link "Delete account" }.to change {User.count}.by(-1) expect { click_link 'Delete account' }.to change { User.count }.by(-1)
expect(current_path).to eq(new_user_session_path) expect(current_path).to eq(new_user_session_path)
end end
end end
describe "when signup is disabled" do describe 'when signup is disabled' do
before do before do
ApplicationSetting.any_instance.stub(signup_enabled?: false) ApplicationSetting.any_instance.stub(signup_enabled?: false)
visit profile_account_path visit profile_account_path
end end
it "should not have option to remove account" do it 'should not have option to remove account' do
expect(page).not_to have_content("Remove account") expect(page).not_to have_content('Remove account')
expect(current_path).to eq(profile_account_path) expect(current_path).to eq(profile_account_path)
end end
end end
......
...@@ -46,7 +46,8 @@ describe ApplicationHelper do ...@@ -46,7 +46,8 @@ describe ApplicationHelper do
group = create(:group) group = create(:group)
group.avatar = File.open(avatar_file_path) group.avatar = File.open(avatar_file_path)
group.save! group.save!
expect(group_icon(group.path).to_s).to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png") expect(group_icon(group.path).to_s).
to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end end
it 'should give default avatar_icon when no avatar is present' do it 'should give default avatar_icon when no avatar is present' do
...@@ -86,7 +87,8 @@ describe ApplicationHelper do ...@@ -86,7 +87,8 @@ describe ApplicationHelper do
user = create(:user) user = create(:user)
user.avatar = File.open(avatar_file_path) user.avatar = File.open(avatar_file_path)
user.save! user.save!
expect(avatar_icon(user.email).to_s).to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png") expect(avatar_icon(user.email).to_s).
to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end end
it 'should return an url for the avatar with relative url' do it 'should return an url for the avatar with relative url' do
...@@ -96,7 +98,8 @@ describe ApplicationHelper do ...@@ -96,7 +98,8 @@ describe ApplicationHelper do
user = create(:user) user = create(:user)
user.avatar = File.open(avatar_file_path) user.avatar = File.open(avatar_file_path)
user.save! user.save!
expect(avatar_icon(user.email).to_s).to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png") expect(avatar_icon(user.email).to_s).
to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end end
it 'should call gravatar_icon when no avatar is present' do it 'should call gravatar_icon when no avatar is present' do
...@@ -120,7 +123,8 @@ describe ApplicationHelper do ...@@ -120,7 +123,8 @@ describe ApplicationHelper do
it 'should return default gravatar url' do it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false) Gitlab.config.gitlab.stub(https: false)
expect(gravatar_icon(user_email)).to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') url = 'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118'
expect(gravatar_icon(user_email)).to match(url)
end end
it 'should use SSL when appropriate' do it 'should use SSL when appropriate' do
...@@ -130,8 +134,11 @@ describe ApplicationHelper do ...@@ -130,8 +134,11 @@ describe ApplicationHelper do
it 'should return custom gravatar path when gravatar_url is set' do it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false)) allow(self).to receive(:request).and_return(double(:ssl? => false))
allow(Gitlab.config.gravatar).to receive(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}') allow(Gitlab.config.gravatar).
expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118') to receive(:plain_url).
and_return('http://example.local/?s=%{size}&hash=%{hash}')
url = 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
expect(gravatar_icon(user_email, 20)).to eq(url)
end end
it 'should accept a custom size' do it 'should accept a custom size' do
...@@ -146,7 +153,8 @@ describe ApplicationHelper do ...@@ -146,7 +153,8 @@ describe ApplicationHelper do
it 'should be case insensitive' do it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false)) allow(self).to receive(:request).and_return(double(:ssl? => false))
expect(gravatar_icon(user_email)).to eq(gravatar_icon(user_email.upcase + ' ')) expect(gravatar_icon(user_email)).
to eq(gravatar_icon(user_email.upcase + ' '))
end end
end end
...@@ -170,7 +178,7 @@ describe ApplicationHelper do ...@@ -170,7 +178,7 @@ describe ApplicationHelper do
it 'includes a list of tag names' do it 'includes a list of tag names' do
expect(options[1][0]).to eq('Tags') expect(options[1][0]).to eq('Tags')
expect(options[1][1]).to include('v1.0.0','v1.1.0') expect(options[1][1]).to include('v1.0.0', 'v1.1.0')
end end
it 'includes a specific commit ref if defined' do it 'includes a specific commit ref if defined' do
...@@ -183,9 +191,11 @@ describe ApplicationHelper do ...@@ -183,9 +191,11 @@ describe ApplicationHelper do
it 'sorts tags in a natural order' do it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data # Stub repository.tag_names to make sure we get some valid testing data
expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a']) expect(@project.repository).to receive(:tag_names).
and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
expect(options[1][1]).to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']) expect(options[1][1]).
to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
end end
end end
......
...@@ -14,7 +14,8 @@ describe BroadcastMessagesHelper do ...@@ -14,7 +14,8 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") } before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
it "should have a customized style" do it "should have a customized style" do
expect(broadcast_styling(broadcast_message)).to match('background-color:#f2dede;color:#b94a48') expect(broadcast_styling(broadcast_message)).
to match('background-color:#f2dede;color:#b94a48')
end end
end end
end end
......
...@@ -10,7 +10,7 @@ describe DiffHelper do ...@@ -10,7 +10,7 @@ describe DiffHelper do
describe 'diff_hard_limit_enabled?' do describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do it 'should return true if param is provided' do
allow(controller).to receive(:params) { { :force_show_diff => true } } allow(controller).to receive(:params) { { force_show_diff: true } }
expect(diff_hard_limit_enabled?).to be_truthy expect(diff_hard_limit_enabled?).to be_truthy
end end
...@@ -21,7 +21,7 @@ describe DiffHelper do ...@@ -21,7 +21,7 @@ describe DiffHelper do
describe 'allowed_diff_size' do describe 'allowed_diff_size' do
it 'should return hard limit for a diff if force diff is true' do it 'should return hard limit for a diff if force diff is true' do
allow(controller).to receive(:params) { { :force_show_diff => true } } allow(controller).to receive(:params) { { force_show_diff: true } }
expect(allowed_diff_size).to eq(1000) expect(allowed_diff_size).to eq(1000)
end end
...@@ -32,13 +32,15 @@ describe DiffHelper do ...@@ -32,13 +32,15 @@ describe DiffHelper do
describe 'parallel_diff' do describe 'parallel_diff' do
it 'should return an array of arrays containing the parsed diff' do it 'should return an array of arrays containing the parsed diff' do
expect(parallel_diff(diff_file, 0)).to match_array(parallel_diff_result_array) expect(parallel_diff(diff_file, 0)).
to match_array(parallel_diff_result_array)
end end
end end
describe 'generate_line_code' do describe 'generate_line_code' do
it 'should generate correct line code' do it 'should generate correct line code' do
expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6') expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).
to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
end end
end end
...@@ -55,12 +57,13 @@ describe DiffHelper do ...@@ -55,12 +57,13 @@ describe DiffHelper do
describe 'diff_line_content' do describe 'diff_line_content' do
it 'should return non breaking space when line is empty' do it 'should return non breaking space when line is empty' do
expect(diff_line_content(nil)).to eq(" &nbsp;") expect(diff_line_content(nil)).to eq(' &nbsp;')
end end
it 'should return the line itself' do it 'should return the line itself' do
expect(diff_line_content(diff_file.diff_lines.first.text)).to eq("@@ -6,12 +6,18 @@ module Popen") expect(diff_line_content(diff_file.diff_lines.first.text)).
expect(diff_line_content(diff_file.diff_lines.first.type)).to eq("match") to eq('@@ -6,12 +6,18 @@ module Popen')
expect(diff_line_content(diff_file.diff_lines.first.type)).to eq('match')
expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6) expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
end end
end end
......
require "spec_helper" require 'spec_helper'
describe GitlabMarkdownHelper do describe GitlabMarkdownHelper do
include ApplicationHelper include ApplicationHelper
...@@ -42,7 +42,8 @@ describe GitlabMarkdownHelper do ...@@ -42,7 +42,8 @@ describe GitlabMarkdownHelper do
end end
it "should not touch HTML entities" do it "should not touch HTML entities" do
allow(@project.issues).to receive(:where).with(id: '39').and_return([issue]) allow(@project.issues).to receive(:where).
with(id: '39').and_return([issue])
actual = 'We&#39;ll accept good pull requests.' actual = 'We&#39;ll accept good pull requests.'
expect(gfm(actual)).to eq("We'll accept good pull requests.") expect(gfm(actual)).to eq("We'll accept good pull requests.")
end end
...@@ -156,7 +157,8 @@ describe GitlabMarkdownHelper do ...@@ -156,7 +157,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected) expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference # Append some text to the end of the reference
expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected) expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
to match(expected)
end end
it "should keep whitespace intact" do it "should keep whitespace intact" do
...@@ -216,9 +218,8 @@ describe GitlabMarkdownHelper do ...@@ -216,9 +218,8 @@ describe GitlabMarkdownHelper do
) )
# Append some text to the end of the reference # Append some text to the end of the reference
expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).to( expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).
match(expected) to(match(expected))
)
end end
it 'should keep whitespace intact' do it 'should keep whitespace intact' do
...@@ -315,7 +316,8 @@ describe GitlabMarkdownHelper do ...@@ -315,7 +316,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected) expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference # Append some text to the end of the reference
expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected) expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
to match(expected)
end end
it "should keep whitespace intact" do it "should keep whitespace intact" do
...@@ -471,7 +473,8 @@ describe GitlabMarkdownHelper do ...@@ -471,7 +473,8 @@ describe GitlabMarkdownHelper do
expect(groups[0]).to match(/This should finally fix $/) expect(groups[0]).to match(/This should finally fix $/)
# First issue link # First issue link
expect(groups[1]).to match(/href="#{project_issue_url(project, issues[0])}"/) expect(groups[1]).
to match(/href="#{project_issue_url(project, issues[0])}"/)
expect(groups[1]).to match(/##{issues[0].iid}$/) expect(groups[1]).to match(/##{issues[0].iid}$/)
# Internal commit link # Internal commit link
...@@ -479,7 +482,8 @@ describe GitlabMarkdownHelper do ...@@ -479,7 +482,8 @@ describe GitlabMarkdownHelper do
expect(groups[2]).to match(/ and /) expect(groups[2]).to match(/ and /)
# Second issue link # Second issue link
expect(groups[3]).to match(/href="#{project_issue_url(project, issues[1])}"/) expect(groups[3]).
to match(/href="#{project_issue_url(project, issues[1])}"/)
expect(groups[3]).to match(/##{issues[1].iid}$/) expect(groups[3]).to match(/##{issues[1].iid}$/)
# Trailing commit link # Trailing commit link
...@@ -494,7 +498,8 @@ describe GitlabMarkdownHelper do ...@@ -494,7 +498,8 @@ describe GitlabMarkdownHelper do
it "escapes HTML passed in as the body" do it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see ##{issues[0].iid}" actual = "This is a <h1>test</h1> - see ##{issues[0].iid}"
expect(link_to_gfm(actual, commit_path)).to match('&lt;h1&gt;test&lt;/h1&gt;') expect(link_to_gfm(actual, commit_path)).
to match('&lt;h1&gt;test&lt;/h1&gt;')
end end
end end
...@@ -508,16 +513,20 @@ describe GitlabMarkdownHelper do ...@@ -508,16 +513,20 @@ describe GitlabMarkdownHelper do
it "should handle references in headers" do it "should handle references in headers" do
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}" actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>}) expect(markdown(actual, no_header_anchors: true)).
expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>}) to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
expect(markdown(actual, no_header_anchors: true)).
to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
end end
it "should add ids and links to headers" do it "should add ids and links to headers" do
# Test every rule except nested tags. # Test every rule except nested tags.
text = '..Ab_c-d. e..' text = '..Ab_c-d. e..'
id = 'ab_c-d-e' id = 'ab_c-d-e'
expect(markdown("# #{text}")).to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>}) expect(markdown("# #{text}")).
expect(markdown("# #{text}", {no_header_anchors:true})).to eq("<h1>#{text}</h1>") to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
expect(markdown("# #{text}", {no_header_anchors:true})).
to eq("<h1>#{text}</h1>")
id = 'link-text' id = 'link-text'
expect(markdown("# [link text](url) ![img alt](url)")).to match( expect(markdown("# [link text](url) ![img alt](url)")).to match(
...@@ -530,13 +539,16 @@ describe GitlabMarkdownHelper do ...@@ -530,13 +539,16 @@ describe GitlabMarkdownHelper do
actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}" actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}"
expect(markdown(actual)).to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>}) expect(markdown(actual)).
expect(markdown(actual)).to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>}) to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
expect(markdown(actual)).
to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
end end
it "should not link the apostrophe to issue 39" do it "should not link the apostrophe to issue 39" do
project.team << [user, :master] project.team << [user, :master]
allow(project.issues).to receive(:where).with(iid: '39').and_return([issue]) allow(project.issues).
to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, it is @#{member.user.username}'s task." actual = "Yes, it is @#{member.user.username}'s task."
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/ expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
...@@ -545,7 +557,8 @@ describe GitlabMarkdownHelper do ...@@ -545,7 +557,8 @@ describe GitlabMarkdownHelper do
it "should not link the apostrophe to issue 39 in code blocks" do it "should not link the apostrophe to issue 39 in code blocks" do
project.team << [user, :master] project.team << [user, :master]
allow(project.issues).to receive(:where).with(iid: '39').and_return([issue]) allow(project.issues).
to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, `it is @#{member.user.username}'s task.`" actual = "Yes, `it is @#{member.user.username}'s task.`"
expected = /Yes, <code>it is @gfm\'s task.<\/code>/ expected = /Yes, <code>it is @gfm\'s task.<\/code>/
...@@ -555,7 +568,8 @@ describe GitlabMarkdownHelper do ...@@ -555,7 +568,8 @@ describe GitlabMarkdownHelper do
it "should handle references in <em>" do it "should handle references in <em>" do
actual = "Apply _!#{merge_request.iid}_ ASAP" actual = "Apply _!#{merge_request.iid}_ ASAP"
expect(markdown(actual)).to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>}) expect(markdown(actual)).
to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
end end
it "should handle tables" do it "should handle tables" do
...@@ -572,8 +586,10 @@ describe GitlabMarkdownHelper do ...@@ -572,8 +586,10 @@ describe GitlabMarkdownHelper do
target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n" target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).to eq(target_html) expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).
expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).to eq(target_html) to eq(target_html)
expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).
to eq(target_html)
end end
it "should leave inline code untouched" do it "should leave inline code untouched" do
......
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