diff --git a/app/views/errs/_issue_tracker_links.html.haml b/app/views/errs/_issue_tracker_links.html.haml index 28f17efa2..3ea642eff 100644 --- a/app/views/errs/_issue_tracker_links.html.haml +++ b/app/views/errs/_issue_tracker_links.html.haml @@ -6,7 +6,10 @@ %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue" = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post - else - - if current_user.can_create_github_issues? && @app.github_repo? - %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" + - if @app.github_repo? + - if current_user.can_create_github_issues? + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" + - elsif @app.issue_tracker_configured? && @app.issue_tracker.is_a?(GithubIssuesTracker) + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "github_create create-issue" - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker) %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.label}_create create-issue" diff --git a/spec/views/errs/show.html.haml_spec.rb b/spec/views/errs/show.html.haml_spec.rb index a2b9da593..270cb3c68 100644 --- a/spec/views/errs/show.html.haml_spec.rb +++ b/spec/views/errs/show.html.haml_spec.rb @@ -13,6 +13,12 @@ controller.stub(:current_user) { Fabricate(:user) } end + def with_issue_tracker(tracker, problem) + problem.app.issue_tracker = tracker.new :api_token => "token token token", :project_id => "1234" + assign :problem, problem + assign :app, problem.app + end + describe "content_for :action_bar" do def action_bar view.content_for(:action_bar) @@ -68,6 +74,16 @@ def action_bar action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') end + + it 'should allow creating issue for github if application has a github tracker' do + problem = Fabricate(:problem_with_comments, :app => Fabricate(:app, :github_repo => "test_user/test_repo")) + with_issue_tracker(GithubIssuesTracker, problem) + assign :problem, problem + assign :app, problem.app + render + + action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') + end end end @@ -87,15 +103,9 @@ def action_bar end context "with issue tracker" do - def with_issue_tracker(problem) - problem.app.issue_tracker = PivotalLabsTracker.new :api_token => "token token token", :project_id => "1234" - assign :problem, problem - assign :app, problem.app - end - it 'should not display the comments section' do problem = Fabricate(:problem) - with_issue_tracker(problem) + with_issue_tracker(PivotalLabsTracker, problem) render view.view_flow.get(:comments).should be_blank end @@ -103,7 +113,7 @@ def with_issue_tracker(problem) it 'should display existing comments' do problem = Fabricate(:problem_with_comments) problem.reload - with_issue_tracker(problem) + with_issue_tracker(PivotalLabsTracker, problem) render view.content_for(:comments).should include('Test comment')