Commit 04c8caad148e09886086ab06830dd75a1da21e71
Exists in
colab
and in
4 other branches
Merge pull request #140 from mezuro/processing_reload_fix
Processing reload fix
Showing
4 changed files
with
7 additions
and
21 deletions
Show diff stats
app/controllers/repositories_controller.rb
| ... | ... | @@ -71,9 +71,7 @@ class RepositoriesController < ApplicationController |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | respond_to do |format| |
| 74 | - if @processing.nil? | |
| 75 | - format.js { render action: 'unprocessed' } | |
| 76 | - elsif @processing.state == 'READY' | |
| 74 | + if @processing.state == 'READY' | |
| 77 | 75 | format.js { render action: 'load_ready_processing' } |
| 78 | 76 | elsif @processing.state == 'ERROR' |
| 79 | 77 | format.js { render action: 'load_error' } | ... | ... |
app/views/repositories/reload_processing.js.erb
| 1 | -$('div#processing_information').html('<%= escape_javascript(render partial: "processing_information") %>'); | |
| 2 | -repository = new Module.Repository(<%= @repository.project_id %>, <%= @repository.id %>) | |
| 3 | -repository.schedule_poll_state('<%= @processing.state %>') | |
| 4 | 1 | \ No newline at end of file |
| 2 | +// This if prevents it from updating the repository's state after the user leaves its page | |
| 3 | +if(document.URL == '<%= project_repository_url(@repository.project_id, @repository) %>'){ | |
| 4 | + $('div#processing_information').html('<%= escape_javascript(render partial: "processing_information") %>'); | |
| 5 | + repository = new Module.Repository(<%= @repository.project_id %>, <%= @repository.id %>) | |
| 6 | + repository.schedule_poll_state('<%= @processing.state %>') | |
| 7 | +} | ... | ... |
app/views/repositories/unprocessed.js.erb
spec/controllers/repositories_controller_spec.rb
| ... | ... | @@ -246,18 +246,6 @@ describe RepositoriesController, :type => :controller do |
| 246 | 246 | describe 'state' do |
| 247 | 247 | let(:repository) { FactoryGirl.build(:repository) } |
| 248 | 248 | |
| 249 | - context 'with no processing at all' do | |
| 250 | - before :each do | |
| 251 | - repository.expects(:last_processing).returns(nil) | |
| 252 | - Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | |
| 253 | - | |
| 254 | - xhr :get, :state, {project_id: project.id.to_s, id: repository.id, last_state: ''} | |
| 255 | - end | |
| 256 | - | |
| 257 | - it { is_expected.to respond_with(:success) } | |
| 258 | - it { is_expected.to render_template(:unprocessed) } | |
| 259 | - end | |
| 260 | - | |
| 261 | 249 | context 'with a READY state' do |
| 262 | 250 | let(:ready_processing) { FactoryGirl.build(:processing) } |
| 263 | 251 | ... | ... |