Skip to content

Commit

Permalink
fixes issue errbit#201
Browse files Browse the repository at this point in the history
  • Loading branch information
mtylty committed Jun 13, 2012
1 parent 854e1cb commit ac5639e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
7 changes: 5 additions & 2 deletions app/views/errs/_issue_tracker_links.html.haml
Expand Up @@ -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"
26 changes: 18 additions & 8 deletions spec/views/errs/show.html.haml_spec.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -87,23 +103,17 @@ 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

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')
Expand Down

0 comments on commit ac5639e

Please sign in to comment.