Skip to content
Snippets Groups Projects
Commit 026e9885 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen
Browse files

Even more hound fixes

parent 5bb743ef
No related branches found
No related tags found
No related merge requests found
Showing
with 266 additions and 191 deletions
Loading
Loading
@@ -45,7 +45,7 @@ describe Projects::BlobController do
 
context 'redirect to tree' do
let(:id) { 'markdown/doc' }
it "redirects" do
it 'redirects' do
expect(subject).
to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
end
Loading
Loading
Loading
Loading
@@ -31,8 +31,8 @@ describe Projects::CommitController do
end
 
it "should not escape Html" do
allow_any_instance_of(Commit).to receive(:"to_#{format}")
.and_return('HTML entities &<>" ')
allow_any_instance_of(Commit).to receive(:"to_#{format}").
and_return('HTML entities &<>" ')
 
get :show, project_id: project.to_param, id: commit.id, format: format
 
Loading
Loading
Loading
Loading
@@ -12,9 +12,9 @@ describe Import::GithubController do
token = "asdasd12345"
allow_any_instance_of(Gitlab::GithubImport::Client).
to receive(:get_token).and_return(token)
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123",
app_secret: "asd123",
name: "github")
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: 'asd123',
app_secret: 'asd123',
name: 'github')
 
get :callback
 
Loading
Loading
Loading
Loading
@@ -50,7 +50,11 @@ describe Projects::TreeController do
 
context 'redirect to blob' do
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
Loading
Loading
@@ -33,15 +33,17 @@ describe "Admin::Users", feature: true do
it "should apply defaults to user" do
click_button "Create user"
user = User.find_by(username: 'bang')
expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
expect(user.projects_limit).
to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group).
to eq(Gitlab.config.gitlab.default_can_create_group)
end
 
it "should create user with valid data" do
click_button "Create user"
user = User.find_by(username: 'bang')
expect(user.name).to eq("Big Bang")
expect(user.email).to eq("bigbang@mail.com")
expect(user.name).to eq('Big Bang')
expect(user.email).to eq('bigbang@mail.com')
end
 
it "should call send mail" do
Loading
Loading
@@ -54,7 +56,7 @@ describe "Admin::Users", feature: true do
click_button "Create user"
user = User.find_by(username: 'bang')
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('password')
end
Loading
Loading
@@ -80,8 +82,8 @@ describe "Admin::Users", feature: true do
end
 
it "should have user edit page" do
expect(page).to have_content("Name")
expect(page).to have_content("Password")
expect(page).to have_content('Name')
expect(page).to have_content('Password')
end
 
describe "Update user" do
Loading
Loading
@@ -93,13 +95,13 @@ describe "Admin::Users", feature: true do
end
 
it "should show page with new data" do
expect(page).to have_content("bigbang@mail.com")
expect(page).to have_content("Big Bang")
expect(page).to have_content('bigbang@mail.com')
expect(page).to have_content('Big Bang')
end
 
it "should change user entry" do
@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
end
end
Loading
Loading
Loading
Loading
@@ -17,12 +17,13 @@ describe "Dashboard Issues Feed", feature: true do
it "should render atom feed via private token" do
visit issues_dashboard_path(:atom, private_token: user.private_token)
 
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{user.name} issues")
expect(body).to have_selector("author email", text: issue1.author_email)
expect(body).to have_selector("entry summary", text: issue1.title)
expect(body).to have_selector("author email", text: issue2.author_email)
expect(body).to have_selector("entry summary", text: issue2.title)
expect(response_headers['Content-Type']).
to have_content('application/atom+xml')
expect(body).to have_selector('title', text: "#{user.name} issues")
expect(body).to have_selector('author email', text: issue1.author_email)
expect(body).to have_selector('entry summary', text: issue1.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
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ describe "Dashboard Feed", feature: true do
context "projects atom feed via private token" do
it "should render projects atom feed" do
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
 
Loading
Loading
@@ -28,7 +28,8 @@ describe "Dashboard Feed", feature: true do
end
 
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
Loading
Loading
require 'spec_helper'
 
describe "Issues Feed", feature: true do
describe "GET /issues" do
describe 'Issues Feed', feature: true do
describe 'GET /issues' do
let!(:user) { create(:user) }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) }
 
before { project.team << [user, :developer] }
 
context "when authenticated" do
it "should render atom feed" do
context 'when authenticated' do
it 'should render atom feed' do
login_with user
visit project_issues_path(project, :atom)
 
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{project.name} issues")
expect(body).to have_selector("author email", text: issue.author_email)
expect(body).to have_selector("entry summary", text: issue.title)
expect(response_headers['Content-Type']).
to have_content('application/atom+xml')
expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
end
end
 
context "when authenticated via private token" do
it "should render atom feed" do
visit project_issues_path(project, :atom, private_token: user.private_token)
context 'when authenticated via private token' do
it 'should render atom feed' do
visit project_issues_path(project, :atom,
private_token: user.private_token)
 
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{project.name} issues")
expect(body).to have_selector("author email", text: issue.author_email)
expect(body).to have_selector("entry summary", text: issue.title)
expect(response_headers['Content-Type']).
to have_content('application/atom+xml')
expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
end
end
end
Loading
Loading
Loading
Loading
@@ -4,17 +4,23 @@ describe "User Feed", feature: true do
describe "GET /" do
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
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
 
context 'feed content' do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project, author: user, description: '') }
let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }
let(:issue) do
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
project.team << [user, :master]
Loading
Loading
@@ -23,11 +29,11 @@ describe "User Feed", feature: true do
visit user_path(user, :atom, private_token: user.private_token)
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}")
end
 
it "should have issue comment event" do
it 'should have issue comment event' do
expect(body).
to have_content("#{safe_name} commented on issue ##{issue.iid}")
end
Loading
Loading
require 'spec_helper'
 
describe "Issues", feature: true do
describe 'Issues', feature: true do
include SortingHelper
 
let(:project) { create(:project) }
Loading
Loading
@@ -12,7 +12,7 @@ describe "Issues", feature: true do
project.team << [[@user, user2], :developer]
end
 
describe "Edit issue" do
describe 'Edit issue' do
let!(:issue) do
create(:issue,
author: @user,
Loading
Loading
@@ -25,30 +25,34 @@ describe "Issues", feature: true do
click_link "Edit"
end
 
it "should open new issue popup" do
it 'should open new issue popup' do
expect(page).to have_content("Issue ##{issue.iid}")
end
 
describe "fill in" do
describe 'fill in' do
before do
fill_in "issue_title", with: "bug 345"
fill_in "issue_description", with: "bug description"
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
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
click_button "Save changes"
it 'should update issue fields' do
click_button 'Save changes'
 
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
end
end
 
end
 
describe "Editing issue assignee" do
describe 'Editing issue assignee' do
let!(:issue) do
create(:issue,
author: @user,
Loading
Loading
@@ -56,7 +60,7 @@ describe "Issues", feature: true do
project: project)
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)
 
expect(page).to have_content "Assign to #{@user.name}"
Loading
Loading
@@ -65,14 +69,14 @@ describe "Issues", feature: true do
sleep 2 # wait for ajax stuff to complete
first('.user-result').click
 
click_button "Save changes"
click_button 'Save changes'
 
expect(page).to have_content 'Assignee: none'
expect(issue.reload.assignee).to be_nil
end
end
 
describe "Filter issue" do
describe 'Filter issue' do
before do
['foobar', 'barbaz', 'gitlab'].each do |title|
create(:issue,
Loading
Loading
@@ -90,7 +94,7 @@ describe "Issues", feature: true do
 
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')
 
expect(page).not_to have_content 'foobar'
Loading
Loading
@@ -98,7 +102,7 @@ describe "Issues", feature: true do
expect(page).to have_content 'gitlab'
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)
 
expect(page).to have_content 'foobar'
Loading
Loading
@@ -106,7 +110,7 @@ describe "Issues", feature: true do
expect(page).not_to have_content 'gitlab'
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')
 
expect(page).to have_content 'foobar'
Loading
Loading
@@ -114,7 +118,7 @@ describe "Issues", feature: true do
expect(page).not_to have_content 'gitlab'
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)
 
expect(page).not_to have_content 'foobar'
Loading
Loading
@@ -126,7 +130,11 @@ describe "Issues", feature: true do
describe 'filter issue' do
titles = ['foo','bar','baz']
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
let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
Loading
Loading
@@ -134,15 +142,15 @@ describe "Issues", feature: true do
it 'sorts by newest' do
visit project_issues_path(project, sort: sort_value_recently_created)
 
expect(first_issue).to include("foo")
expect(last_issue).to include("baz")
expect(first_issue).to include('foo')
expect(last_issue).to include('baz')
end
 
it 'sorts by oldest' do
visit project_issues_path(project, sort: sort_value_oldest_created)
 
expect(first_issue).to include("baz")
expect(last_issue).to include("foo")
expect(first_issue).to include('baz')
expect(last_issue).to include('foo')
end
 
it 'sorts by most recently updated' do
Loading
Loading
@@ -150,7 +158,7 @@ describe "Issues", feature: true do
baz.save
visit project_issues_path(project, sort: sort_value_recently_updated)
 
expect(first_issue).to include("baz")
expect(first_issue).to include('baz')
end
 
it 'sorts by least recently updated' do
Loading
Loading
@@ -158,7 +166,7 @@ describe "Issues", feature: true do
baz.save
visit project_issues_path(project, sort: sort_value_oldest_updated)
 
expect(first_issue).to include("baz")
expect(first_issue).to include('baz')
end
 
describe 'sorting by milestone' do
Loading
Loading
@@ -172,13 +180,13 @@ describe "Issues", feature: true do
it 'sorts by recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_soon)
 
expect(first_issue).to include("foo")
expect(first_issue).to include('foo')
end
 
it 'sorts by least recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_later)
 
expect(first_issue).to include("bar")
expect(first_issue).to include('bar')
end
end
 
Loading
Loading
@@ -193,10 +201,12 @@ describe "Issues", feature: true do
end
 
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(last_issue).to include("foo")
expect(first_issue).to include('bar')
expect(last_issue).to include('foo')
expect(page).not_to have_content 'baz'
end
end
Loading
Loading
@@ -210,11 +220,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do
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'
 
expect(page).to have_content "Assignee:"
has_select?('issue_assignee_id', :selected => project.team.members.first.name)
expect(page).to have_content 'Assignee:'
has_select?('issue_assignee_id',
selected: project.team.members.first.name)
end
end
 
Loading
Loading
@@ -228,7 +240,7 @@ describe "Issues", feature: true do
issue.save
end
 
it "shows assignee text", js: true do
it 'shows assignee text', js: true do
logout
login_with guest
 
Loading
Loading
@@ -247,12 +259,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do
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'
 
expect(page).to have_content "Milestone changed to #{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
 
Loading
Loading
@@ -265,7 +278,7 @@ describe "Issues", feature: true do
issue.save
end
 
it "shows milestone text", js: true do
it 'shows milestone text', js: true do
logout
login_with guest
 
Loading
Loading
@@ -282,7 +295,7 @@ describe "Issues", feature: true do
issue.save
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)
expect(page).to have_content "Assignee: #{user2.name}"
 
Loading
Loading
@@ -298,10 +311,10 @@ describe "Issues", feature: true do
end
 
def first_issue
all("ul.issues-list li").first.text
all('ul.issues-list li').first.text
end
 
def last_issue
all("ul.issues-list li").last.text
all('ul.issues-list li').last.text
end
end
Loading
Loading
@@ -3,10 +3,12 @@ require 'spec_helper'
describe 'Comments' do
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!(: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
login_as :admin
Loading
Loading
@@ -15,19 +17,20 @@ describe 'Comments' do
 
subject { page }
 
describe "the note form" do
describe 'the note form' do
it 'should be valid' do
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")
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')
within('.js-main-target-form') do
expect(page).not_to have_link('Cancel')
end
end
 
describe "with text" do
describe 'with text' do
before do
within(".js-main-target-form") do
fill_in "note[note]", with: "This is awesome"
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awesome'
end
end
 
Loading
Loading
@@ -40,41 +43,45 @@ describe 'Comments' do
end
end
 
describe "when posting a note" do
describe 'when posting a note' do
before do
within(".js-main-target-form") do
fill_in "note[note]", with: "This is awsome!"
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awsome!'
find('.js-md-preview-button').click
click_button "Add Comment"
click_button 'Add Comment'
end
end
 
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
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).to have_css('.js-md-preview', visible: :hidden)
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
 
describe "when editing a note", js: true do
it "should contain the hidden edit form" do
within("#note_#{note.id}") { is_expected.to have_css(".note-edit-form", visible: false) }
describe 'when editing a note', js: true do
it 'should contain the hidden edit form' do
within("#note_#{note.id}") do
is_expected.to have_css('.note-edit-form', visible: false)
end
end
 
describe "editing the note" do
describe 'editing the note' do
before do
find('.note').hover
find(".js-note-edit").click
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
expect(find(".current-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('.current-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
end
end
 
Loading
Loading
@@ -87,41 +94,43 @@ describe 'Comments' do
#end
#end
 
it "appends the edited at time to the note" do
within(".current-note-edit-form") do
fill_in "note[note]", with: "Some new content"
find(".btn-save").click
it 'appends the edited at time to the note' do
within('.current-note-edit-form') do
fill_in 'note[note]', with: 'Some new content'
find('.btn-save').click
end
 
within("#note_#{note.id}") do
is_expected.to have_css(".note_edited_ago")
expect(find(".note_edited_ago").text).to match(/less than a minute ago/)
is_expected.to have_css('.note_edited_ago')
expect(find('.note_edited_ago').text).
to match(/less than a minute ago/)
end
end
end
 
describe "deleting an attachment" do
describe 'deleting an attachment' do
before do
find('.note').hover
find(".js-note-edit").click
find('.js-note-edit').click
end
 
it "shows the delete link" do
within(".note-attachment") do
is_expected.to have_css(".js-note-attachment-delete")
it 'shows the delete link' do
within('.note-attachment') do
is_expected.to have_css('.js-note-attachment-delete')
end
end
 
it "removes the attachment div and resets the edit form" do
find(".js-note-attachment-delete").click
is_expected.not_to have_css(".note-attachment")
expect(find(".current-note-edit-form", visible: false)).not_to be_visible
it 'removes the attachment div and resets the edit form' do
find('.js-note-attachment-delete').click
is_expected.not_to have_css('.note-attachment')
expect(find('.current-note-edit-form', visible: false)).
not_to be_visible
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(:project) { merge_request.source_project }
 
Loading
Loading
@@ -132,68 +141,74 @@ describe 'Comments' do
 
subject { page }
 
describe "when adding a note" do
describe 'when adding a note' do
before do
click_diff_line
end
 
describe "the notes holder" do
it { is_expected.to have_css(".js-temp-notes-holder") }
describe 'the notes holder' do
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
 
describe "the note form" do
describe 'the note form' do
it "shouldn't add a second form for same row" do
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
 
it "should be removed when canceled" do
it 'should be removed when canceled' 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
 
is_expected.to have_no_css(".js-temp-notes-holder")
is_expected.to have_no_css('.js-temp-notes-holder')
end
end
end
 
describe "with muliple note forms" do
describe 'with muliple note forms' do
before do
click_diff_line
click_diff_line(line_code_2)
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
# add two separate texts and trigger previews on both
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
end
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
end
end
end
 
describe "posting a note" do
describe 'posting a note' do
before do
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10"
click_button("Add Comment")
fill_in 'note[note]', with: 'Another comment on line 10'
click_button('Add Comment')
end
end
 
it 'should be added as discussion' do
is_expected.to have_content("Another comment on line 10")
is_expected.to have_css(".notes_holder")
is_expected.to have_css(".notes_holder .note", count: 1)
is_expected.to have_content('Another comment on line 10')
is_expected.to have_css('.notes_holder')
is_expected.to have_css('.notes_holder .note', count: 1)
is_expected.to have_button('Reply')
end
end
Loading
Loading
require 'spec_helper'
 
describe "Profile account page", feature: true do
describe 'Profile account page', feature: true do
let(:user) { create(:user) }
 
before do
login_as :user
end
 
describe "when signup is enabled" do
describe 'when signup is enabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: true)
visit profile_account_path
end
 
it { expect(page).to have_content("Remove account") }
it { expect(page).to have_content('Remove account') }
 
it "should delete the account" do
expect { click_link "Delete account" }.to change {User.count}.by(-1)
it 'should delete the account' do
expect { click_link 'Delete account' }.to change { User.count }.by(-1)
expect(current_path).to eq(new_user_session_path)
end
end
 
describe "when signup is disabled" do
describe 'when signup is disabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: false)
visit profile_account_path
end
 
it "should not have option to remove account" do
expect(page).not_to have_content("Remove account")
it 'should not have option to remove account' do
expect(page).not_to have_content('Remove account')
expect(current_path).to eq(profile_account_path)
end
end
Loading
Loading
Loading
Loading
@@ -46,7 +46,8 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
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
 
it 'should give default avatar_icon when no avatar is present' do
Loading
Loading
@@ -86,7 +87,8 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
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
 
it 'should return an url for the avatar with relative url' do
Loading
Loading
@@ -96,7 +98,8 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
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
 
it 'should call gravatar_icon when no avatar is present' do
Loading
Loading
@@ -120,7 +123,8 @@ describe ApplicationHelper do
 
it 'should return default gravatar url' do
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
 
it 'should use SSL when appropriate' do
Loading
Loading
@@ -130,8 +134,11 @@ describe ApplicationHelper do
 
it 'should return custom gravatar path when gravatar_url is set' do
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}')
expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118')
allow(Gitlab.config.gravatar).
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
 
it 'should accept a custom size' do
Loading
Loading
@@ -146,7 +153,8 @@ describe ApplicationHelper do
 
it 'should be case insensitive' do
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
 
Loading
Loading
@@ -170,7 +178,7 @@ describe ApplicationHelper do
 
it 'includes a list of tag names' do
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
 
it 'includes a specific commit ref if defined' do
Loading
Loading
@@ -183,9 +191,11 @@ describe ApplicationHelper do
 
it 'sorts tags in a natural order' do
# 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
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,8 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
 
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
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ describe DiffHelper do
 
describe 'diff_hard_limit_enabled?' 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
end
 
Loading
Loading
@@ -21,7 +21,7 @@ describe DiffHelper do
 
describe 'allowed_diff_size' 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)
end
 
Loading
Loading
@@ -32,13 +32,15 @@ describe DiffHelper do
 
describe 'parallel_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
 
describe 'generate_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
 
Loading
Loading
@@ -55,12 +57,13 @@ describe DiffHelper do
describe 'diff_line_content' 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
 
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.type)).to eq("match")
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.type)).to eq('match')
expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
end
end
Loading
Loading
require "spec_helper"
require 'spec_helper'
 
describe GitlabMarkdownHelper do
include ApplicationHelper
Loading
Loading
@@ -42,7 +42,8 @@ describe GitlabMarkdownHelper do
end
 
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.'
expect(gfm(actual)).to eq("We'll accept good pull requests.")
end
Loading
Loading
@@ -156,7 +157,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
 
# 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
 
it "should keep whitespace intact" do
Loading
Loading
@@ -216,9 +218,8 @@ describe GitlabMarkdownHelper do
)
 
# Append some text to the end of the reference
expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).to(
match(expected)
)
expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).
to(match(expected))
end
 
it 'should keep whitespace intact' do
Loading
Loading
@@ -315,7 +316,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
 
# 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
 
it "should keep whitespace intact" do
Loading
Loading
@@ -471,7 +473,8 @@ describe GitlabMarkdownHelper do
expect(groups[0]).to match(/This should finally fix $/)
 
# 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}$/)
 
# Internal commit link
Loading
Loading
@@ -479,7 +482,8 @@ describe GitlabMarkdownHelper do
expect(groups[2]).to match(/ and /)
 
# 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}$/)
 
# Trailing commit link
Loading
Loading
@@ -494,7 +498,8 @@ describe GitlabMarkdownHelper do
 
it "escapes HTML passed in as the body" do
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
 
Loading
Loading
@@ -508,16 +513,20 @@ describe GitlabMarkdownHelper do
it "should handle references in headers" do
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})).to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
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)).
to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
end
 
it "should add ids and links to headers" do
# Test every rule except nested tags.
text = '..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}", {no_header_anchors:true})).to eq("<h1>#{text}</h1>")
expect(markdown("# #{text}")).
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'
expect(markdown("# [link text](url) ![img alt](url)")).to match(
Loading
Loading
@@ -530,13 +539,16 @@ describe GitlabMarkdownHelper do
 
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)).to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
expect(markdown(actual)).
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
 
it "should not link the apostrophe to issue 39" do
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."
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
Loading
Loading
@@ -545,7 +557,8 @@ describe GitlabMarkdownHelper do
 
it "should not link the apostrophe to issue 39 in code blocks" do
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.`"
expected = /Yes, <code>it is @gfm\'s task.<\/code>/
Loading
Loading
@@ -555,7 +568,8 @@ describe GitlabMarkdownHelper do
it "should handle references in <em>" do
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
 
it "should handle tables" do
Loading
Loading
@@ -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"
 
expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).to eq(target_html)
expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).to eq(target_html)
expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).
to eq(target_html)
expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).
to eq(target_html)
end
 
it "should leave inline code untouched" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment