Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

day 14

  • Loading branch information...
commit 472c970169db43f5eb346555c39f1f6f56f48e67 1 parent fa84e59
@typester authored
View
83 script/insert_default_data.pl
@@ -7,86 +7,7 @@
use DateTime;
use Jobeet::Models;
-# create default Categories
-for my $category_name (qw/Design Programming Manager Administrator/) {
- models('Schema::Category')->create({ name => $category_name });
-}
+my $datafile = models('home')->subdir(qw/sql fixtures/)->file('default.pl');
+do $datafile or die $!;
-# create default Jobs
-my $programming_category =
- models('Schema::Category')->find({ name => 'Programming' });
-$programming_category->add_to_jobs({
- type => 'full-time',
- company => 'Sensio Labs',
- logo => 'sensio-labs.gif',
- url => 'http://www.sensiolabs.com/',
- position => 'Web Developer',
- location => 'Paris, France',
- description => q[You've already developed websites with symfony and you want to work with Open-Source technologies. You have a minimum of 3 years experience in web development with PHP or Java and you wish to participate to development of Web 2.0 sites using the best frameworks available.],
- how_to_apply => 'Send your resume to fabien.potencier [at] sensio.com',
- is_public => 1,
- is_activated => 1,
- token => 'job_sensio_labs',
- email => 'job@example.com',
- expires_at => '2010-10-10',
-});
-my $design_category = models('Schema::Category')->find({ name => 'Design' });
-$design_category->add_to_jobs({
- type => 'part-time',
- company => 'Extreme Sensio',
- logo => 'extreme-sensio.gif',
- url => 'http://www.extreme-sensio.com/',
- position => 'Web Designer',
- location => 'Paris, France',
- description => q[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Utenim ad minim veniam, quis nostrud exercitation ullamco laborisnisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in. Voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpaqui officia deserunt mollit anim id est laborum.],
- how_to_apply => 'Send your resume to fabien.potencier [at] sensio.com',
- is_public => 1,
- is_activated => 1,
- token => 'job_extreme_sensio',
- email => 'job@example.com',
- expires_at => '2010-10-10',
-});
-
-{
- my $cat_programming = models('Schema::Category')->find({ name => 'Programming' });
- my $job = models('Schema::Job')->create({
- category_id => $cat_programming->id,
- company => 'Sensio Labs',
- position => 'Web Developer',
- location => 'Paris, France',
- description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
- how_to_apply => 'Send your resume to lorem.ipsum [at] dolor.sit',
- is_public => 1,
- is_activated => 1,
- token => 'job_expired',
- email => 'job@example.com',
- });
- $job->update({
- created_at => '2005-12-01',
- expires_at => '2005-12-31',
- });
-}
-
-
-{
- my $job_rs = models('Schema::Job');
- my $cat_rs = models('Schema::Category');
-
- my $cat_programming = $cat_rs->find({ name => 'Programming' });
-
- for my $i (100 .. 130) {
- my $job = $job_rs->create({
- category_id => $cat_programming->id,
- company => "Company $i",
- position => 'Web Developer',
- location => 'Paris, France',
- description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
- how_to_apply => "Send your resume to lorem.ipsum [at] company_${i}.sit",
- is_public => 1,
- is_activated => 1,
- token => "job_$i",
- email => 'job@example.com',
- });
- }
-}
View
87 sql/fixtures/default.pl
@@ -0,0 +1,87 @@
+# create default Categories
+for my $category_name (qw/Design Programming Manager Administrator/) {
+ models('Schema::Category')->create({
+ name => $category_name
+ });
+}
+
+# create default Jobs
+my $programming_category =
+ models('Schema::Category')->find({ name => 'Programming' });
+$programming_category->add_to_jobs({
+ type => 'full-time',
+ company => 'Sensio Labs',
+ logo => 'sensio-labs.gif',
+ url => 'http://www.sensiolabs.com/',
+ position => 'Web Developer',
+ location => 'Paris, France',
+ description => q[You've already developed websites with symfony and you want to work with Open-Source technologies. You have a minimum of 3 years experience in web development with PHP or Java and you wish to participate to development of Web 2.0 sites using the best frameworks available.],
+ how_to_apply => 'Send your resume to fabien.potencier [at] sensio.com',
+ is_public => 1,
+ is_activated => 1,
+ token => 'job_sensio_labs',
+ email => 'job@example.com',
+ expires_at => '2010-10-10',
+});
+
+my $design_category = models('Schema::Category')->find({ name => 'Design' });
+$design_category->add_to_jobs({
+ type => 'part-time',
+ company => 'Extreme Sensio',
+ logo => 'extreme-sensio.gif',
+ url => 'http://www.extreme-sensio.com/',
+ position => 'Web Designer',
+ location => 'Paris, France',
+ description => q[Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Utenim ad minim veniam, quis nostrud exercitation ullamco laborisnisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in. Voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpaqui officia deserunt mollit anim id est laborum.],
+ how_to_apply => 'Send your resume to fabien.potencier [at] sensio.com',
+ is_public => 1,
+ is_activated => 1,
+ token => 'job_extreme_sensio',
+ email => 'job@example.com',
+ expires_at => '2010-10-10',
+});
+
+{
+ my $cat_programming = models('Schema::Category')->find({ name => 'Programming' });
+ my $job = models('Schema::Job')->create({
+ category_id => $cat_programming->id,
+ company => 'Sensio Labs',
+ position => 'Web Developer',
+ location => 'Paris, France',
+ description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
+ how_to_apply => 'Send your resume to lorem.ipsum [at] dolor.sit',
+ is_public => 1,
+ is_activated => 1,
+ token => 'job_expired',
+ email => 'job@example.com',
+ });
+ $job->update({
+ created_at => '2005-12-01',
+ expires_at => '2005-12-31',
+ });
+}
+
+
+{
+ my $job_rs = models('Schema::Job');
+ my $cat_rs = models('Schema::Category');
+
+ my $cat_programming = $cat_rs->find({ name => 'Programming' });
+
+ for my $i (100 .. 130) {
+ my $job = $job_rs->create({
+ category_id => $cat_programming->id,
+ company => "Company $i",
+ position => 'Web Developer',
+ location => 'Paris, France',
+ description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
+ how_to_apply => "Send your resume to lorem.ipsum [at] company_${i}.sit",
+ is_public => 1,
+ is_activated => 1,
+ token => "job_$i",
+ email => 'job@example.com',
+ });
+ }
+}
+
+1;
View
38 t/controller/category.t
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Jobeet::Test;
+use Jobeet::Models;
+
+my $datafile = models('home')->subdir(qw/sql fixtures/)->file('default.pl');
+do $datafile or die $!;
+
+{
+ my $c = ctx_get('/category/foo');
+ is $c->req->action->reverse, 'category/show', 'action called ok';
+ is $c->res->status, '404', '404 status ok';
+ ok !$c->stash->{category}, 'category not set';
+ ok !$c->stash->{jobs}, 'jobs not set';
+}
+
+{
+ my $c = ctx_get('/category/design');
+ is $c->req->action->reverse, 'category/show', 'action called ok';
+ is $c->res->status, '200', '200 status ok';
+ isa_ok $c->stash->{category}, 'Jobeet::Schema::Result::Category';
+ isa_ok $c->stash->{jobs}, 'Jobeet::Schema::ResultSet::Job';
+ is $c->stash->{category}->slug, 'design', 'slug ok';
+}
+
+{
+ my $c = ctx_get('/category/programming');
+ is $c->stash->{jobs}->pager->current_page, 1, 'current page 1 ok';
+}
+
+{
+ my $c = ctx_get('/category/programming?page=2');
+ is $c->stash->{jobs}->pager->current_page, 2, 'current page 2 ok';
+}
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.