diff --git a/app/views/stopwatch_issue_timers/stop.js.erb b/app/views/stopwatch_issue_timers/stop.js.erb index 0df980b..b5698a5 100644 --- a/app/views/stopwatch_issue_timers/stop.js.erb +++ b/app/views/stopwatch_issue_timers/stop.js.erb @@ -1,6 +1,6 @@ contextMenuHide(); window.stopwatch.updateStartStopLink( '#stopwatch_stop_timer_<%= @issue.id %>', - '<%= j Stopwatch::IssueLinks.new(@issue).start_timer %>' + '<%= j Stopwatch::IssueLinks.new(@issue, self).start_timer %>' ); window.stopwatch.timerStopped(); diff --git a/assets/javascripts/stopwatch.js b/assets/javascripts/stopwatch.js index db4c6ed..f5e68fc 100644 --- a/assets/javascripts/stopwatch.js +++ b/assets/javascripts/stopwatch.js @@ -74,7 +74,7 @@ window.initStopwatch = function(config){ $('a.stopwatch_issue_timer').each(function(){ var a = $(this); a.attr('href', a.attr('href').replace(/stop$/, 'start')); - a.text(locales.startTimer); + a.find('span').text(locales.startTimer); }); }, timerStarted: function(data){ @@ -94,10 +94,10 @@ window.initStopwatch = function(config){ if(data.issue_id) { if(a.data('issueId') == data.issue_id) { a.attr('href', href.replace(/start$/, 'stop')); - a.text(locales.stopTimer); + a.find('span').text(locales.stopTimer); } else { a.attr('href', href.replace(/stop$/, 'start')); - a.text(locales.startTimer); + a.find('span').text(locales.startTimer); } } }); diff --git a/lib/stopwatch/issue_links.rb b/lib/stopwatch/issue_links.rb index 88b0fde..2ee692b 100644 --- a/lib/stopwatch/issue_links.rb +++ b/lib/stopwatch/issue_links.rb @@ -4,7 +4,7 @@ module Stopwatch context.link_to( context.sprite_icon(:time, I18n.t(:label_stopwatch_start)), context.start_issue_timer_path(issue), - class: 'stopwatch_issue_timer', + class: 'icon stopwatch_issue_timer', data: { issue_id: issue.id }, remote: true, method: 'post' @@ -15,7 +15,7 @@ module Stopwatch context.link_to( context.sprite_icon(:time, I18n.t(:label_stopwatch_stop)), context.stop_issue_timer_path(issue), - class: 'stopwatch_issue_timer', + class: 'icon stopwatch_issue_timer', data: { issue_id: issue.id }, remote: true, method: 'post' diff --git a/test/integration/ticket_timer_test.rb b/test/integration/ticket_timer_test.rb index 9c18d24..0f7c4f5 100644 --- a/test/integration/ticket_timer_test.rb +++ b/test/integration/ticket_timer_test.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../test_helper', __FILE__) +require File.expand_path('../test_helper', __dir__) class TicketTimerTest < Redmine::IntegrationTest include ActiveJob::TestHelper @@ -30,6 +30,7 @@ class TicketTimerTest < Redmine::IntegrationTest assert_not_running get "/issues/1" + assert_response :success assert_select "div.contextual a", text: /start tracking/i assert_no_difference ->{TimeEntry.count} do post "/issues/1/timer/start", xhr: true @@ -77,7 +78,7 @@ class TicketTimerTest < Redmine::IntegrationTest TimeEntry.delete_all assert_no_difference ->{TimeEntry.count} do post "/issues/1/timer/start", xhr: true - assert_response 200 + assert_response :ok end end @@ -86,7 +87,7 @@ class TicketTimerTest < Redmine::IntegrationTest TimeEntry.delete_all with_settings plugin_stopwatch: { 'default_activity' => 'system'} do post "/issues/1/timer/start", xhr: true - assert_response 201 + assert_response :created end assert te = TimeEntry.last assert_equal 1, te.issue_id @@ -98,18 +99,17 @@ class TicketTimerTest < Redmine::IntegrationTest TimeEntry.delete_all with_settings plugin_stopwatch: { 'default_activity' => '9'} do post "/issues/1/timer/start", xhr: true - assert_response 201 + assert_response :created end assert te = TimeEntry.last assert_equal 1, te.issue_id assert_equal 9, te.activity_id end - private def assert_not_running - refute Stopwatch::Timer.new(User.find(@user.id)).running? + assert_not Stopwatch::Timer.new(User.find(@user.id)).running? end def assert_running