diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 4f433f3..5977c9c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -37,23 +37,23 @@ module IssuesHelper end end - def url_for_issue(issue_id) + def url_for_issue(issue_iid) return "" if @project.nil? if @project.used_default_issues_tracker? - url = project_issue_url project_id: @project, id: issue_id + url = project_issue_url project_id: @project, id: issue_iid else url = Gitlab.config.issues_tracker[@project.issues_tracker]["issues_url"] - url.gsub(':id', issue_id.to_s) + url.gsub(':id', issue_iid.to_s) .gsub(':project_id', @project.id.to_s) .gsub(':issues_tracker_id', @project.issues_tracker_id.to_s) end end - def title_for_issue(issue_id) + def title_for_issue(issue_iid) return "" if @project.nil? - if @project.used_default_issues_tracker? && issue = @project.issues.where(id: issue_id).first + if @project.used_default_issues_tracker? && issue = @project.issues.where(iid: issue_iid).first issue.title else "" diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb index d344e3e..3c1a9cb 100644 --- a/spec/controllers/merge_requests_controller_spec.rb +++ b/spec/controllers/merge_requests_controller_spec.rb @@ -8,13 +8,13 @@ describe Projects::MergeRequestsController do before do sign_in(user) project.team << [user, :master] - Projects::MergeRequestsController.any_instance.stub(validates_merge_request: true) + Projects::MergeRequestsController.any_instance.stub(validates_merge_request: true, ) end describe "#show" do shared_examples "export merge as" do |format| it "should generally work" do - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response).to be_success end @@ -22,11 +22,11 @@ describe Projects::MergeRequestsController do it "should generate it" do MergeRequest.any_instance.should_receive(:"to_#{format}") - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format end it "should render it" do - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s) end @@ -34,7 +34,7 @@ describe Projects::MergeRequestsController do it "should not escape Html" do MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ') - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response.body).to_not include('&') expect(response.body).to_not include('>') @@ -48,7 +48,7 @@ describe Projects::MergeRequestsController do let(:format) { :diff } it "should really only be a git diff" do - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response.body).to start_with("diff --git") end @@ -59,24 +59,13 @@ describe Projects::MergeRequestsController do let(:format) { :patch } it "should really be a git email patch with commit" do - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") end - # TODO: fix or remove - #it "should contain as many patches as there are commits" do - #get :show, project_id: project.code, id: merge_request.id, format: format - - #patch_count = merge_request.commits.count - #merge_request.commits.each_with_index do |commit, patch_num| - #expect(response.body).to match(/^From #{commit.id}/) - #expect(response.body).to match(/^Subject: \[PATCH #{patch_num}\/#{patch_count}\]/) - #end - #end - it "should contain git diffs" do - get :show, project_id: project.code, id: merge_request.id, format: format + get :show, project_id: project.code, id: merge_request.iid, format: format expect(response.body).to match(/^diff --git/) end diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 2dcc61e..a4db8b4 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -20,7 +20,7 @@ describe GitlabMarkdownHelper do describe "#gfm" do it "should return unaltered text if project is nil" do - actual = "Testing references: ##{issue.id}" + actual = "Testing references: ##{issue.iid}" gfm(actual).should_not == actual @@ -175,14 +175,14 @@ describe GitlabMarkdownHelper do describe "referencing an issue" do let(:object) { issue } - let(:reference) { "##{issue.id}" } + let(:reference) { "##{issue.iid}" } include_examples 'referenced object' end describe "referencing a merge request" do let(:object) { merge_request } - let(:reference) { "!#{merge_request.id}" } + let(:reference) { "!#{merge_request.iid}" } include_examples 'referenced object' end @@ -230,7 +230,7 @@ describe GitlabMarkdownHelper do end describe "referencing multiple objects" do - let(:actual) { "!#{merge_request.id} -> #{commit.id} -> ##{issue.id}" } + let(:actual) { "!#{merge_request.iid} -> #{commit.id} -> ##{issue.iid}" } it "should link to the merge request" do expected = project_merge_request_path(project, merge_request) @@ -299,7 +299,7 @@ describe GitlabMarkdownHelper do let(:issues) { create_list(:issue, 2, project: project) } it "should handle references nested in links with all the text" do - actual = link_to_gfm("This should finally fix ##{issues[0].id} and ##{issues[1].id} for real", commit_path) + actual = link_to_gfm("This should finally fix ##{issues[0].iid} and ##{issues[1].iid} for real", commit_path) # Break the result into groups of links with their content, without # closing tags @@ -311,7 +311,7 @@ describe GitlabMarkdownHelper do # First issue link groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/) - groups[1].should match(/##{issues[0].id}$/) + groups[1].should match(/##{issues[0].iid}$/) # Internal commit link groups[2].should match(/href="#{commit_path}"/) @@ -319,7 +319,7 @@ describe GitlabMarkdownHelper do # Second issue link groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/) - groups[3].should match(/##{issues[1].id}$/) + groups[3].should match(/##{issues[1].iid}$/) # Trailing commit link groups[4].should match(/href="#{commit_path}"/) @@ -332,7 +332,7 @@ describe GitlabMarkdownHelper do end it "escapes HTML passed in as the body" do - actual = "This is a

test

- see ##{issues[0].id}" + actual = "This is a

test

- see ##{issues[0].iid}" link_to_gfm(actual, commit_path).should match('<h1>test</h1>') end end @@ -345,25 +345,25 @@ describe GitlabMarkdownHelper do end it "should handle references in headers" do - actual = "\n# Working around ##{issue.id}\n## Apply !#{merge_request.id}" + actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}" - markdown(actual).should match(%r{Working around ##{issue.id}}) - markdown(actual).should match(%r{Apply !#{merge_request.id}}) + markdown(actual).should match(%r{Working around ##{issue.iid}}) + markdown(actual).should match(%r{Apply !#{merge_request.iid}}) end it "should handle references in lists" do project.team << [user, :master] - actual = "\n* dark: ##{issue.id}\n* light by @#{member.user.username}" + actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}" - markdown(actual).should match(%r{
  • dark: ##{issue.id}
  • }) + markdown(actual).should match(%r{
  • dark: ##{issue.iid}
  • }) markdown(actual).should match(%r{
  • light by @#{member.user.username}
  • }) end it "should handle references in " do - actual = "Apply _!#{merge_request.id}_ ASAP" + actual = "Apply _!#{merge_request.iid}_ ASAP" - markdown(actual).should match(%r{Apply !#{merge_request.id}}) + markdown(actual).should match(%r{Apply !#{merge_request.iid}}) end it "should leave code blocks untouched" do @@ -379,19 +379,19 @@ describe GitlabMarkdownHelper do end it "should leave ref-like autolinks untouched" do - markdown("look at http://example.tld/#!#{merge_request.id}").should == "

    look at http://example.tld/#!#{merge_request.id}

    \n" + markdown("look at http://example.tld/#!#{merge_request.iid}").should == "

    look at http://example.tld/#!#{merge_request.iid}

    \n" end it "should leave ref-like href of 'manual' links untouched" do - markdown("why not [inspect !#{merge_request.id}](http://example.tld/#!#{merge_request.id})").should == "

    why not inspect !#{merge_request.id}

    \n" + markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "

    why not inspect !#{merge_request.iid}

    \n" end it "should leave ref-like src of images untouched" do - markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.id})").should == "

    screen shot: \"some

    \n" + markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.iid})").should == "

    screen shot: \"some

    \n" end it "should generate absolute urls for refs" do - markdown("##{issue.id}").should include(project_issue_url(project, issue)) + markdown("##{issue.iid}").should include(project_issue_url(project, issue)) end it "should generate absolute urls for emoji" do diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index a1f2307..3595af3 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -8,7 +8,7 @@ describe IssuesHelper do describe :title_for_issue do it "should return issue title if used internal tracker" do @project = project - title_for_issue(issue.id).should eq issue.title + title_for_issue(issue.iid).should eq issue.title end it "should always return empty string if used external tracker" do @@ -61,7 +61,7 @@ describe IssuesHelper do it "should return internal path if used internal tracker" do @project = project - url_for_issue(issue.id).should match(int_expected) + url_for_issue(issue.iid).should match(int_expected) end it "should return path to external tracker" do @@ -73,7 +73,7 @@ describe IssuesHelper do it "should return empty string if project nil" do @project = nil - url_for_issue(issue.id).should eq "" + url_for_issue(issue.iid).should eq "" end end diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 551e175..852146e 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -11,7 +11,9 @@ describe Issue, "Issuable" do end describe "Validation" do + before { subject.stub(set_iid: false) } it { should validate_presence_of(:project) } + it { should validate_presence_of(:iid) } it { should validate_presence_of(:author) } it { should validate_presence_of(:title) } it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } -- libgit2 0.21.2