Commit ac5639ecb803b104673d65087779b130484d4d80
1 parent
854e1cbb
Exists in
master
and in
1 other branch
fixes issue #201
Showing
2 changed files
with
23 additions
and
10 deletions
Show diff stats
app/views/errs/_issue_tracker_links.html.haml
@@ -6,7 +6,10 @@ | @@ -6,7 +6,10 @@ | ||
6 | %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue" | 6 | %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue" |
7 | = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post | 7 | = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post |
8 | - else | 8 | - else |
9 | - - if current_user.can_create_github_issues? && @app.github_repo? | ||
10 | - %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" | 9 | + - if @app.github_repo? |
10 | + - if current_user.can_create_github_issues? | ||
11 | + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" | ||
12 | + - elsif @app.issue_tracker_configured? && @app.issue_tracker.is_a?(GithubIssuesTracker) | ||
13 | + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "github_create create-issue" | ||
11 | - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker) | 14 | - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker) |
12 | %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.label}_create create-issue" | 15 | %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.label}_create create-issue" |
spec/views/errs/show.html.haml_spec.rb
@@ -13,6 +13,12 @@ describe "errs/show.html.haml" do | @@ -13,6 +13,12 @@ describe "errs/show.html.haml" do | ||
13 | controller.stub(:current_user) { Fabricate(:user) } | 13 | controller.stub(:current_user) { Fabricate(:user) } |
14 | end | 14 | end |
15 | 15 | ||
16 | + def with_issue_tracker(tracker, problem) | ||
17 | + problem.app.issue_tracker = tracker.new :api_token => "token token token", :project_id => "1234" | ||
18 | + assign :problem, problem | ||
19 | + assign :app, problem.app | ||
20 | + end | ||
21 | + | ||
16 | describe "content_for :action_bar" do | 22 | describe "content_for :action_bar" do |
17 | def action_bar | 23 | def action_bar |
18 | view.content_for(:action_bar) | 24 | view.content_for(:action_bar) |
@@ -68,6 +74,16 @@ describe "errs/show.html.haml" do | @@ -68,6 +74,16 @@ describe "errs/show.html.haml" do | ||
68 | 74 | ||
69 | action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') | 75 | action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') |
70 | end | 76 | end |
77 | + | ||
78 | + it 'should allow creating issue for github if application has a github tracker' do | ||
79 | + problem = Fabricate(:problem_with_comments, :app => Fabricate(:app, :github_repo => "test_user/test_repo")) | ||
80 | + with_issue_tracker(GithubIssuesTracker, problem) | ||
81 | + assign :problem, problem | ||
82 | + assign :app, problem.app | ||
83 | + render | ||
84 | + | ||
85 | + action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') | ||
86 | + end | ||
71 | end | 87 | end |
72 | end | 88 | end |
73 | 89 | ||
@@ -87,15 +103,9 @@ describe "errs/show.html.haml" do | @@ -87,15 +103,9 @@ describe "errs/show.html.haml" do | ||
87 | end | 103 | end |
88 | 104 | ||
89 | context "with issue tracker" do | 105 | context "with issue tracker" do |
90 | - def with_issue_tracker(problem) | ||
91 | - problem.app.issue_tracker = PivotalLabsTracker.new :api_token => "token token token", :project_id => "1234" | ||
92 | - assign :problem, problem | ||
93 | - assign :app, problem.app | ||
94 | - end | ||
95 | - | ||
96 | it 'should not display the comments section' do | 106 | it 'should not display the comments section' do |
97 | problem = Fabricate(:problem) | 107 | problem = Fabricate(:problem) |
98 | - with_issue_tracker(problem) | 108 | + with_issue_tracker(PivotalLabsTracker, problem) |
99 | render | 109 | render |
100 | view.view_flow.get(:comments).should be_blank | 110 | view.view_flow.get(:comments).should be_blank |
101 | end | 111 | end |
@@ -103,7 +113,7 @@ describe "errs/show.html.haml" do | @@ -103,7 +113,7 @@ describe "errs/show.html.haml" do | ||
103 | it 'should display existing comments' do | 113 | it 'should display existing comments' do |
104 | problem = Fabricate(:problem_with_comments) | 114 | problem = Fabricate(:problem_with_comments) |
105 | problem.reload | 115 | problem.reload |
106 | - with_issue_tracker(problem) | 116 | + with_issue_tracker(PivotalLabsTracker, problem) |
107 | render | 117 | render |
108 | 118 | ||
109 | view.content_for(:comments).should include('Test comment') | 119 | view.content_for(:comments).should include('Test comment') |