Skip to content

Commit

Permalink
add a test for events on matrix build pages.
Browse files Browse the repository at this point in the history
surprisingly this passes, even though there are issues on this page, so the test isn't really useful, yet
  • Loading branch information
Sven Fuchs committed Apr 10, 2011
1 parent 31ebc9b commit 4af3d29
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 4 deletions.
22 changes: 22 additions & 0 deletions play/ruby_rvm_system.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env ruby

# https://gist.github.com/raw/909740/102dc1f17d605f299d6d91d5462f73a56a10c7e3/ruby_rvm_system_invocation.rb

# How to run a system command from ruby within a clean bash that has never sourced rvm using a custom ruby version

# 1) install rvm as the correct user
# 2) do NOT follow the instructions about sourcing and adding this to your .bashrc
# 3) run the following (change the versions accordingly)

ruby_versions = %w(ruby-1.8.7-p302 ruby-1.9.2-p0)

ruby_versions.each do |version|
puts ('>' * 20) + " #{version}"
%w(true false).each do |bool|
puts %Q~the following should output "#{bool}"~
p system(%(bash -c 'FOO=#{version}; source "/Volumes/Users/sven/.rvm/scripts/rvm"; rvm use #{version}; ruby -v; echo "echo $FOO"; #{bool}'))
puts ('=' * 20)
end
puts ('<' * 20)
end

4 changes: 2 additions & 2 deletions public/javascripts/app/views/repository/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Travis.Views.Repository.Show = Backbone.View.extend({
this._setTitle();
_.each(this.tabs, function(tab) { tab.attachTo(repository); }.bind(this));
},
activateTab: function(name, buildId) {
activateTab: function(name) {
_.each(this.tabs, function(tab) { if(tab.name != name) tab.deactivate(); })
this.tabs[name].activate(buildId);
this.tabs[name].activate();
},
_createTab: function(name) {
this.tabs[name] = new Travis.Views.Repository.Tab({ name: name });
Expand Down
74 changes: 74 additions & 0 deletions public/javascripts/tests/integration/build_matrix_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
describe('Running a build matrix', function() {
var PAYLOADS = {
'build:queued:1': { repository: { id: 1, slug: 'svenfuchs/minimal' }, build: { id: 3, number: 3, } },
'build:started:1': { repository: { id: 1, slug: 'svenfuchs/minimal' }, build: { id: 3, number: 3, started_at: '2010-11-12T17:00:00Z', commit: '1111111', committer_name: 'Sven Fuchs', message: 'gem-minimal commit' } },
'build:expanded:1': { repository: { id: 1 }, build: { id: 3, config: { rvm: ['1.8.7', '1.9.2'] }, matrix: [ { id: 4, parent_id: 3, number: '3.1', config: { gemfile: 'test/Gemfile.rails-2.3.x', rvm: '1.8.7' } }, { id: 5, parent_id: 3, number: '3.2', config: { gemfile: 'test/Gemfile.rails-3.0.x', rvm: '1.8.7' } }, { id: 6, parent_id: 3, number: '3.3', config: { gemfile: 'test/Gemfile.rails-2.3.x', rvm: '1.9.2' } }, { id: 7, parent_id: 3, number: '3.4', config: { gemfile: 'test/Gemfile.rails-3.0.x', rvm: '1.9.2' } } ] } },
'build:log:1': { repository: { id: 1 }, build: { id: 4, }, log: ' with appended chars' },
'build:finished:1': { repository: { id: 1 }, build: { id: 4, status: 0, finished_at: '2010-11-12T17:00:10Z' } },
};
var trigger = function(event, payload, expectations) {
runs(function() { Travis.trigger(event, payload); });
waits(50);
if(expectations) runs(expectations);
};

beforeEach(function() {
startApp();
goTo('/');
waitsFor(repositoriesListPopulated());
});

afterEach(function() {
stopApp();
});

it('schedules the build job, expands the matrix and runs each build', function() {
trigger('build:queued', PAYLOADS['build:queued:1'], function() {
// expect job list to contain job
expectText('#jobs li:nth-child(3)', 'svenfuchs/minimal #3');
});

trigger('build:started', PAYLOADS['build:started:1'], function() {
expect($('#jobs').html()).not.toHaveText(/svenfuchs\/minimal #3/);
// expect repository list to contain the repo
expect('#repositories li:nth-child(1)').toListRepository({ slug: 'svenfuchs/minimal', build: 3, selected: true, color: undefined, finished_at: '-', duration: '4 hrs 30 sec' });
// expect the current tab to show the build
expect($('#tab_current')).toShowBuildSummary({ build: 3, commit: '1111111', committer: 'Sven Fuchs', finished_at: '-', duration: '30 sec' });
});

trigger('build:expanded', PAYLOADS['build:expanded:1'], function() {
// expect the current tab to show the build matrix
expect('#tab_current #matrix').toMatchTable([
['Build', 'Gemfile', 'Rvm' ],
['3.1', 'test/Gemfile.rails-2.3.x', '1.8.7'],
['3.2', 'test/Gemfile.rails-3.0.x', '1.8.7'],
]);
});

goTo('svenfuchs/minimal/builds/4');
runsAfter(10, function() {
// expect the build child tab to be active and show the child build #3.1
expect($('#tab_build.active h5')).toHaveText('Build 3.1');
// expect the build child tab to show the build details
expect($('#tab_build.active .summary')).not.toBeEmpty();
})

trigger('build:log', PAYLOADS['build:log:1'], function() {
// expect the build child tab to be active
expect($('#tab_build.active h5')).toHaveText('Build 3.1');
// expect the build child tab to show the details
expect($('#tab_build.active .summary')).not.toBeEmpty();
// expect the build child tab to show the updated log
expect($('#tab_build.active .log')).toHaveText('minimal build 3 log ... with appended chars');
});

trigger('build:finished', PAYLOADS['build:finished:1'], function() {
// expect the build child tab to be active
expect($('#tab_build.active h5')).toHaveText('Build 3.1');
// expect the build log to show the log
expect($('#tab_build.active .log')).toHaveText('minimal build 3 log ... with appended chars');
// expect the build to be finished
expect($('#tab_build .finished_at').attr('title')).toBe('2010-11-12T17:00:10Z')
});
});
});
2 changes: 1 addition & 1 deletion public/javascripts/tests/integration/events_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Events:', function() {
});

it('removes the job from the jobs list view', function() {
expect($('#jobs #job_10').length).toBe(0);
expect($('#jobs').html()).not.toHaveText(/svenfuchs\/minimal #4/);
});

it('updates the repository list entry and moves it to the top of the list', function() {
Expand Down
3 changes: 2 additions & 1 deletion public/javascripts/tests/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ var follow = function(text, context) {
});
};

var goTo = function(hash) {
var goTo = function(hash, expectations) {
runs(function() {
window.location.hash = normalizeHash(hash);
Backbone.history.loadUrl();
});
if(expectations) runs(expectations);
};

var normalizeHash = function(hash) {
Expand Down

0 comments on commit 4af3d29

Please sign in to comment.