X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/f34953cad258ff91e1ce024309478c8c50882a87..ac01c25abcbe7d2ede91723ac91d519bd170fd1f:/SL/Controller/JSTests.pm diff --git a/SL/Controller/JSTests.pm b/SL/Controller/JSTests.pm new file mode 100644 index 000000000..1c8a67bd2 --- /dev/null +++ b/SL/Controller/JSTests.pm @@ -0,0 +1,54 @@ +package SL::Controller::JSTests; + +use strict; + +use parent qw(SL::Controller::Base); + +use File::Find (); +use File::Spec (); + +use SL::System::Process; + +use Rose::Object::MakeMethods::Generic +( + 'scalar --get_set_init' => [ qw(all_scripts scripts_to_run) ], +); + +# +# actions +# + +sub action_run { + my ($self) = @_; + + $::request->layout->use_stylesheet("css/qunit.css"); + $self->render('js_tests/run', title => $::locale->text('Run JavaScript unit tests')); +} + +# +# helpers +# + +sub init_all_scripts { + my ($self) = @_; + + my $exe_dir = SL::System::Process->exe_dir; + + my @scripts; + my $wanted = sub { + return if ( ! -f $File::Find::name ) || ($File::Find::name !~ m{\.js$}); + push @scripts, File::Spec->abs2rel($File::Find::name, $exe_dir); + }; + + File::Find::find($wanted, $exe_dir . '/js/t'); + + return \@scripts; +} + +sub init_scripts_to_run { + my ($self) = @_; + my $filter = $::form->{file_filter} || '.'; + return [ grep { m{$filter} } @{ $self->all_scripts } ]; +} + +1;