Commit 72a3058f1aa9b4193b3ac3697a7fb100cc19e0f9

Authored by Stephen Crosby
2 parents 4422b3f4 f8bfb124
Exists in master and in 1 other branch production

Merge pull request #655 from brandedcrate/features/extract_issue_tracker-one_issue_button

have only one 'create issue' button
app/views/problems/_issue_tracker_links.html.haml
... ... @@ -6,10 +6,10 @@
6 6 %span.disabled= link_to 'creating...', '#', :class => "#{problem.issue_type}_inactive create-issue"
7 7 = link_to 'retry', create_issue_app_problem_path(app, problem), :method => :post
8 8 - else
9   - - if app.github_repo?
  9 + - if app.issue_tracker_configured? && !app.issue_tracker.label.eql?('github')
  10 + %span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "#{app.issue_tracker.label}_create create-issue"
  11 + - elsif app.github_repo?
10 12 - if current_user.can_create_github_issues?
11 13 %span= link_to 'create issue', create_issue_app_problem_path(app, problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue"
12 14 - elsif app.issue_tracker_configured? && app.issue_tracker.label.eql?('github')
13 15 %span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "github_create create-issue"
14   - - if app.issue_tracker_configured? && !app.issue_tracker.label.eql?('github')
15   - %span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "#{app.issue_tracker.label}_create create-issue"
... ...
spec/views/problems/show.html.haml_spec.rb
... ... @@ -115,25 +115,49 @@ describe "problems/show.html.haml" do
115 115 before do
116 116 with_issue_tracker("PivotalLabsTracker", problem)
117 117 end
118   - context "with problem without issue link" do
  118 +
  119 + context "with app having github_repo" do
  120 + let(:app) { App.new(:new_record => false, :github_repo => 'foo/bar') }
  121 + let(:problem){ Problem.new(:new_record => false, :app => app) }
  122 +
119 123 before do
120 124 problem.issue_link = nil
  125 + user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef')
  126 + controller.stub(:current_user) { user }
121 127 end
122   - it 'not see link if no issue tracker' do
  128 +
  129 + it 'links to the associated tracker' do
123 130 render
124   - expect(view.content_for(:action_bar)).to match(/create issue/)
  131 + expect(view.content_for(:action_bar)).to match(".pivotal_create.create-issue")
125 132 end
126 133  
  134 + it 'does not link to github' do
  135 + render
  136 + expect(view.content_for(:action_bar)).to_not match(".github_create.create-issue")
  137 + end
127 138 end
128 139  
129   - context "with problem with issue link" do
130   - before do
131   - problem.issue_link = 'http://foo'
  140 + context "without app having github_repo" do
  141 + context "with problem without issue link" do
  142 + before do
  143 + problem.issue_link = nil
  144 + end
  145 + it 'not see link if no issue tracker' do
  146 + render
  147 + expect(view.content_for(:action_bar)).to match(/create issue/)
  148 + end
  149 +
132 150 end
133 151  
134   - it 'not see link if no issue tracker' do
135   - render
136   - expect(view.content_for(:action_bar)).to_not match(/create issue/)
  152 + context "with problem with issue link" do
  153 + before do
  154 + problem.issue_link = 'http://foo'
  155 + end
  156 +
  157 + it 'not see link if no issue tracker' do
  158 + render
  159 + expect(view.content_for(:action_bar)).to_not match(/create issue/)
  160 + end
137 161 end
138 162 end
139 163  
... ...