From 37be920a6ec5ba9299d49891cc5620fe53221ad3 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Sat, 27 Dec 2014 16:40:47 -0500 Subject: [PATCH] Remove some github specific configs, need to be on the plugin --- app/controllers/problems_controller.rb | 5 +++-- app/models/issue_tracker.rb | 2 +- app/views/problems/_issue_tracker_links.html.haml | 10 ++-------- spec/views/problems/show.html.haml_spec.rb | 16 +++------------- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index 855e5eb..7a11d0d 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -63,8 +63,9 @@ class ProblemsController < ApplicationController def create_issue body = "" # TODO render_issue_body - title = "" # TODO generate_title - issue = Issue.new(issue_tracker: problem.app.issue_tracker, user: current_user, title: title, body: body) + title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" + + issue = Issue.new(problem: problem, user: current_user, title: title, body: body) unless issue.save flash[:error] = issue.errors.full_messages.join(', ') end diff --git a/app/models/issue_tracker.rb b/app/models/issue_tracker.rb index 148e9ef..ead852e 100644 --- a/app/models/issue_tracker.rb +++ b/app/models/issue_tracker.rb @@ -13,7 +13,7 @@ class IssueTracker @tracker ||= begin klass = ErrbitPlugin::Registry.issue_trackers[self.type_tracker] || ErrbitPlugin::NoneIssueTracker - klass.new(self.options) + klass.new(options.merge(github_repo: app.github_repo, bitbucket_repo: app.bitbucket_repo)) end end diff --git a/app/views/problems/_issue_tracker_links.html.haml b/app/views/problems/_issue_tracker_links.html.haml index 2df004a..ce765d5 100644 --- a/app/views/problems/_issue_tracker_links.html.haml +++ b/app/views/problems/_issue_tracker_links.html.haml @@ -1,4 +1,4 @@ -- if app.issue_tracker_configured? || current_user.github_account? +- if app.issue_tracker_configured? - if problem.issue_link.present? %span= link_to 'go to issue', problem.issue_link, :class => "#{problem.issue_type}_goto goto-issue" = link_to 'unlink issue', unlink_issue_app_problem_path(app, problem), :method => :delete, :data => { :confirm => "Unlink err issues?" }, :class => "unlink-issue" @@ -6,10 +6,4 @@ %span.disabled= link_to 'creating...', '#', :class => "#{problem.issue_type}_inactive create-issue" = link_to 'retry', create_issue_app_problem_path(app, problem), :method => :post - else - - if app.issue_tracker_configured? && !app.issue_tracker.type_tracker.eql?('github') - %span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "#{app.issue_tracker.type_tracker}_create create-issue" - - elsif app.github_repo? - - if current_user.can_create_github_issues? - %span= link_to 'create issue', create_issue_app_problem_path(app, problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" - - elsif app.issue_tracker_configured? && app.issue_tracker.type_tracker.eql?('github') - %span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "github_create create-issue" + %span= link_to 'create issue', create_issue_app_problem_path(app, problem), method: :post, class: "#{app.issue_tracker.type_tracker}_create create-issue" diff --git a/spec/views/problems/show.html.haml_spec.rb b/spec/views/problems/show.html.haml_spec.rb index a64ff43..048181f 100644 --- a/spec/views/problems/show.html.haml_spec.rb +++ b/spec/views/problems/show.html.haml_spec.rb @@ -81,26 +81,16 @@ describe "problems/show.html.haml" do end context 'create issue links' do - it 'should allow creating issue for github if current user has linked their github account' do - user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef') - controller.stub(:current_user) { user } - - problem = Fabricate(:problem_with_comments, :app => Fabricate(:app, :github_repo => "test_user/test_repo")) - view.stub(:problem).and_return(problem) - view.stub(:app).and_return(problem.app) - render - - expect(action_bar).to have_selector("span a.github_create.create-issue", :text => 'create issue') - end + let(:app) { Fabricate(:app, :github_repo => "test_user/test_repo") } 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")) + problem = Fabricate(:problem_with_comments, app: app) with_issue_tracker("github", problem) view.stub(:problem).and_return(problem) view.stub(:app).and_return(problem.app) render - expect(action_bar).to have_selector("span a.github_create.create-issue", :text => 'create issue') + expect(action_bar).to have_selector("span a.github_create.create-issue", text: 'create issue') end context "without issue tracker associate on app" do -- libgit2 0.21.2