Commit 0ba4249f348138ec91a71f53d60ba785dc124e19
Exists in
master
and in
1 other branch
Merge pull request #202 from nebulab/issue_201
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 | 6 | %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue" |
| 7 | 7 | = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post |
| 8 | 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 | 14 | - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker) |
| 12 | 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 | 13 | controller.stub(:current_user) { Fabricate(:user) } |
| 14 | 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 | 22 | describe "content_for :action_bar" do |
| 17 | 23 | def action_bar |
| 18 | 24 | view.content_for(:action_bar) |
| ... | ... | @@ -68,6 +74,16 @@ describe "errs/show.html.haml" do |
| 68 | 74 | |
| 69 | 75 | action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') |
| 70 | 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 | 87 | end |
| 72 | 88 | end |
| 73 | 89 | |
| ... | ... | @@ -87,15 +103,9 @@ describe "errs/show.html.haml" do |
| 87 | 103 | end |
| 88 | 104 | |
| 89 | 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 | 106 | it 'should not display the comments section' do |
| 97 | 107 | problem = Fabricate(:problem) |
| 98 | - with_issue_tracker(problem) | |
| 108 | + with_issue_tracker(PivotalLabsTracker, problem) | |
| 99 | 109 | render |
| 100 | 110 | view.view_flow.get(:comments).should be_blank |
| 101 | 111 | end |
| ... | ... | @@ -103,7 +113,7 @@ describe "errs/show.html.haml" do |
| 103 | 113 | it 'should display existing comments' do |
| 104 | 114 | problem = Fabricate(:problem_with_comments) |
| 105 | 115 | problem.reload |
| 106 | - with_issue_tracker(problem) | |
| 116 | + with_issue_tracker(PivotalLabsTracker, problem) | |
| 107 | 117 | render |
| 108 | 118 | |
| 109 | 119 | view.content_for(:comments).should include('Test comment') | ... | ... |