radiant-race_results-extension 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -1,5 +1,5 @@
1
- class RaceInstancesController < ApplicationController
2
- radiant_layout { |controller| Radiant::Config['races.results_layout'] || Radiant::Config['races.layout'] }
1
+ class RaceInstancesController < SiteController
2
+ radiant_layout { |controller| Radiant::Config['races.layout'] }
3
3
  no_login_required
4
4
  before_filter :get_race, :only => :show
5
5
 
@@ -12,6 +12,7 @@ class RaceInstancesController < ApplicationController
12
12
  if params[:cat] && @category = @instance.categories.find_by_name(params[:cat])
13
13
  @performances = @performances.eligible_for_category(@category)
14
14
  end
15
+ expires_in 1.month, :private => false, :public => true
15
16
  end
16
17
 
17
18
  private
@@ -1,9 +1,10 @@
1
- class RacePerformancesController < ApplicationController
1
+ class RacePerformancesController < SiteController
2
2
  radiant_layout { |controller| Radiant::Config['races.layout'] }
3
3
  no_login_required
4
4
  before_filter :get_race, :only => :show
5
5
 
6
6
  def show
7
+ expires_in 1.month, :private => false, :public => true
7
8
  @performance = @race.performances.find(params[:id])
8
9
  end
9
10
 
@@ -1,22 +1,16 @@
1
- class RacesController < ApplicationController
1
+ class RacesController < SiteController
2
2
  include Radiant::Pagination::Controller
3
- radiant_layout { |controller| controller.choose_layout }
3
+ radiant_layout { |controller| Radiant::Config['races.layout'] }
4
4
  no_login_required
5
5
 
6
6
  def show
7
7
  @race = Race.find_by_slug(params[:slug])
8
+ expires_in 1.month, :private => false, :public => true
8
9
  end
9
10
 
10
11
  def index
11
12
  @races = Race.paginate(pagination_parameters)
12
- end
13
-
14
- def choose_layout
15
- if action_name == "show"
16
- layout = Radiant::Config['races.show_layout'] || Radiant::Config['races.layout']
17
- else
18
- layout = Radiant::Config['races.index_layout'] || Radiant::Config['races.layout']
19
- end
13
+ expires_in 1.month, :private => false, :public => true
20
14
  end
21
15
 
22
16
  end
@@ -35,4 +35,11 @@ module RacesHelper
35
35
  end
36
36
  end
37
37
 
38
+ def truncate_words(text='', length=64, omission="...")
39
+ return '' if text.blank?
40
+ words = text.split
41
+ omission = '' unless words.size > length
42
+ words[0..(length-1)].join(" ") + omission
43
+ end
44
+
38
45
  end
data/app/models/race.rb CHANGED
@@ -19,12 +19,15 @@ class Race < ActiveRecord::Base
19
19
 
20
20
  validates_presence_of :name, :slug
21
21
  validates_uniqueness_of :name, :slug
22
- validates_length_of :slug, :maximum => 100, :message => '{{count}}-character limit'
22
+ validates_length_of :slug, :maximum => 100, :message => '%{count}-character limit'
23
23
  validates_format_of :slug, :with => %r{^([-_.A-Za-z0-9]*|)$}, :message => 'not URL-friendly'
24
24
 
25
25
  object_id_attr :filter, TextFilter
26
26
 
27
27
  default_scope :order => 'name ASC'
28
+ named_scope :except, lambda { |race|
29
+ { :conditions => ["NOT races.id = ?", race.id] }
30
+ }
28
31
 
29
32
  def to_param
30
33
  slug
@@ -9,7 +9,7 @@ class RaceCheckpointTime < ActiveRecord::Base
9
9
 
10
10
  # validates_presence_of :checkpoint, :performance
11
11
 
12
- named_scope :time_at, lambda {|checkpoint|
12
+ named_scope :at_checkpoint, lambda {|checkpoint|
13
13
  {
14
14
  :conditions => ["race_checkpoint_id = ?", checkpoint.id]
15
15
  }
@@ -45,7 +45,7 @@ class RaceCheckpointTime < ActiveRecord::Base
45
45
  end
46
46
 
47
47
  def previous
48
- performance.checkpoint_times.time_at(checkpoint.previous) if checkpoint.previous
48
+ performance.checkpoint_times.at_checkpoint(checkpoint.previous) if checkpoint.previous
49
49
  end
50
50
 
51
51
  def previous_position
@@ -24,7 +24,7 @@ class RaceInstance < ActiveRecord::Base
24
24
 
25
25
  validates_presence_of :name, :slug, :race
26
26
  validates_uniqueness_of :slug, :scope => :race_id
27
- validates_length_of :slug, :maximum => 100, :message => '{{count}}-character limit'
27
+ validates_length_of :slug, :maximum => 100, :message => '%{count}-character limit'
28
28
  validates_format_of :slug, :with => %r{^([-_.A-Za-z0-9]*|)$}, :message => 'not URL-friendly'
29
29
  default_scope :order => 'started_at DESC'
30
30
 
@@ -140,7 +140,7 @@ protected
140
140
  headers.each do |key|
141
141
  value = runner[normalize(key)]
142
142
  if value && value.looks_like_duration? && cp = race.checkpoints.find_by_name(key)
143
- cp.times.create(:race_performance_id => performance.id, :elapsed_time => value)
143
+ performance.checkpoint_times.create(:race_checkpoint_id => cp, :elapsed_time => value)
144
144
  end
145
145
  end
146
146
  end
@@ -139,7 +139,7 @@ class RacePerformance < ActiveRecord::Base
139
139
  end
140
140
 
141
141
  def time_at(checkpoint)
142
- checkpoint_times.time_at(checkpoint).first
142
+ checkpoint_times.at_checkpoint(checkpoint).first
143
143
  end
144
144
 
145
145
  def status
@@ -1,3 +1,5 @@
1
+ = render :partial => 'races/standard_parts'
2
+
1
3
  - if @instance.has_results?
2
4
  %table.results
3
5
  %thead
@@ -11,15 +13,12 @@
11
13
  Not available yet.
12
14
 
13
15
  - content_for :breadhead do
14
- - home = Page.find_by_parent_id(nil)
15
- = link_to home.breadcrumb, home.url
16
- \&gt;
17
16
  = link_to "Races", races_url
18
- \&gt;
17
+ = t('separator')
19
18
  = link_to @instance.race.name, race_url(@instance.race), :class => 'breadhead'
20
- \&gt;
19
+ = t('separator')
21
20
  = link_to @instance.name, race_instance_url(@instance), :class => 'breadhead'
22
- \&gt;
21
+ = t('separator')
23
22
 
24
23
  - content_for :title do
25
24
  = @instance.full_name
@@ -1,14 +1,16 @@
1
- %h1
2
- = yield :title
3
-
4
- %div.race_list
5
- = yield :list
1
+ = render :partial => 'races/standard_parts'
6
2
 
7
3
  - content_for :title do
8
- Results
4
+ All Results
5
+
6
+ - content_for :breadhead do
7
+ = link_to "Races", races_url
9
8
 
10
9
  - content_for :list do
11
- %ul.race_list
12
- - @race_instances.each do |instance|
13
- %li
14
- = link_to instance.full_name, race_race_instance_url(instance.race, instance) }
10
+ %div.races
11
+ %ul.race_list
12
+ - @race_instances.each do |instance|
13
+ %li
14
+ = link_to instance.full_name, race_race_instance_url(instance.race, instance) }
15
+
16
+ = yield :list
@@ -1,43 +1,37 @@
1
- - if @instance.has_results?
2
- - if @club || @category
3
- %p.subset
4
- Showing only
5
- - if @club
6
- %strong
7
- = @club.name
8
- - if @category
9
- %strong
10
- = @category.name
11
- %br
12
- = link_to "Show all results.", race_instance_url(@race, @instance)
1
+ = render :partial => 'races/standard_parts'
2
+
3
+ - content_for :results do
4
+ - if @instance.has_results?
5
+ - if @club || @category
6
+ %p.subset
7
+ Showing only
8
+ - if @club
9
+ %strong
10
+ = @club.name
11
+ - if @category
12
+ %strong
13
+ = @category.name
14
+ %br
15
+ = link_to "Show all results.", race_instance_url(@race, @instance)
13
16
 
14
- %table.results
15
- %thead
16
- = render :partial => 'race_performances/headings'
17
- %tbody
18
- = render :partial => 'race_performances/performance', :collection => @performances.completed
19
- = render :partial => 'race_performances/performance', :collection => @performances.incomplete, :locals => {:trclass => 'unfinished'}
17
+ %table.results
18
+ %thead
19
+ = render :partial => 'race_performances/headings'
20
+ %tbody
21
+ = render :partial => 'race_performances/performance', :collection => @performances.completed
22
+ = render :partial => 'race_performances/performance', :collection => @performances.incomplete, :locals => {:trclass => 'unfinished'}
20
23
 
21
- - else
22
- %p.noresults
23
- Not available yet.
24
+ - else
25
+ %p.noresults
26
+ Not available yet.
24
27
 
25
28
  - content_for :breadhead do
26
- - home = Page.find_by_parent_id(nil)
27
- = link_to home.breadcrumb, home.url
28
- \&gt;
29
29
  = link_to "Races", races_url, :class => 'breadhead'
30
- \&gt;
30
+ = t('separator')
31
31
  = link_to @instance.race.name, race_url(@instance.race), :class => 'breadhead'
32
32
 
33
33
  - content_for :title do
34
34
  = @instance.full_name
35
-
36
- - content_for :subtitle do
37
- = @race.distance
38
- miles,
39
- = @race.climb
40
- climb
41
35
 
42
36
  - content_for :introduction do
43
37
  - if @instance.past?
@@ -46,12 +40,18 @@
46
40
  = @instance.filter.filter(@instance.notes)
47
41
 
48
42
  - content_for :see_also do
49
- - if others = @race.instances.with_results.select{|i| i != @instance}
50
- .see_also
51
- %p
43
+ .see_also
44
+ %p
45
+ - if others = @race.instances.with_results.select{|i| i != @instance}
52
46
  More
53
47
  = @race.name
54
48
  results:
55
- = others.map { |instance| link_to instance.name, race_instance_url(@race, instance) }.join(', ')
56
-
49
+ = others.map { |instance| link_to instance.name, race_instance_url(@race, instance) }.join(', ') + '.'
50
+ %br
51
+ More races:
52
+ = Race.except(@race).map {|race| link_to race.name, race_url(race) }.join(', ') + '.'
53
+
54
+
57
55
 
56
+ = yield :results
57
+ = yield :see_also
@@ -0,0 +1,4 @@
1
+ - content_for :section_navigation do
2
+ = link_to "Races", races_url, :class => 'section'
3
+ - Race.all.each do |race|
4
+ = link_to race.name, race_url(race)
@@ -1,36 +1,34 @@
1
- - @races.each do |race|
2
- .race
3
- - if race.picture_asset
4
- .race_illustration
5
- = link_to image_tag(race.picture_asset.thumbnail(Radiant::Config['races.race_illustration_size'] || :small)), race_url(race)
1
+ = render :partial => 'races/standard_parts'
2
+
3
+ - content_for :races do
4
+ - @races.each do |race|
5
+ .race
6
+ - if race.picture_asset
7
+ .race_illustration
8
+ = link_to image_tag(race.picture_asset.thumbnail(Radiant::Config['races.race_illustration_size'] || :small)), race_url(race)
6
9
 
7
- .race_description
8
- %h2
9
- = link_to race.name, race_url(race)
10
- %span.headernote
11
- = race.distance
12
- miles,
13
- = race.climb.to_s + "'"
14
-
15
- %p.race_instances
16
- - if next_instance = race.next
17
- Next:
18
- = link_to next_instance.nice_start_date, race_url(race)
19
- %br
20
- - if race.instances.with_results.any?
21
- Results:
22
- = race.instances.with_results.map { |instance| link_to instance.name, race_instance_url(race, instance) }.join(', ')
23
- %br
24
- - if race.map_asset
25
- = link_to "Download map", race.map_asset.thumbnail('original'), :class => 'racemap'
26
-
27
- %p
28
- = truncate_words(race.description, 72)
29
-
30
- - content_for :breadhead do
31
- - home = Page.find_by_parent_id(nil)
32
- = link_to home.breadcrumb, home.url
33
- \&gt;
10
+ .race_description
11
+ %h2
12
+ = link_to race.name, race_url(race)
13
+ %span.headernote
14
+ = race.distance
15
+ miles,
16
+ = race.climb.to_s + "'"
17
+
18
+ %p.race_instances
19
+ - if next_instance = race.next
20
+ Next:
21
+ = link_to next_instance.nice_start_date, race_url(race)
22
+ %br
23
+ - if race.instances.with_results.any?
24
+ Results:
25
+ = race.instances.with_results.map { |instance| link_to instance.name, race_instance_url(race, instance) }.join(', ')
26
+ %br
27
+ - if race.map_asset
28
+ = link_to "Download map", race.map_asset.thumbnail('original'), :class => 'racemap'
29
+
30
+ %p
31
+ = truncate_words(race.description, 72)
34
32
 
35
33
  - content_for :title do
36
34
  Races
@@ -40,3 +38,7 @@
40
38
  %p.next_race
41
39
  Next race:
42
40
  = link_to "#{next_instance.race.name} on #{next_instance.nice_start_date}", race_instance_url(next_instance.race, next_instance)
41
+
42
+
43
+
44
+ = yield :races
@@ -1,37 +1,30 @@
1
+ = render :partial => 'races/standard_parts'
2
+
1
3
  - content_for :breadhead do
2
- - home = Page.find_by_parent_id(nil)
3
- = link_to home.breadcrumb, home.url
4
- \&gt;
5
4
  = link_to "Races", races_url
6
- \&gt;
5
+ = t('separator')
7
6
 
8
7
  - content_for :title do
9
8
  = @race.name
10
9
 
11
10
  - content_for :subtitle do
12
- = @race.distance
11
+ - if @race.cat
12
+ = @race.cat + ":"
13
+ = @race.distance.to_s
13
14
  miles,
14
- = @race.climb
15
- climb
15
+ = @race.climb.to_s + "'"
16
+ climb.
16
17
 
17
18
  - content_for :next do
18
19
  - if next_instance = @race.next
19
20
  Next race:
20
- = next_instance.nice_start_date + ','
21
+ = next_instance.nice_start_date
21
22
  at
22
23
  = next_instance.nice_start_time + "."
23
24
 
24
25
  - content_for :notes do
25
26
  - if next_instance = @race.next
26
27
  = next_instance.filter.filter(next_instance.notes)
27
-
28
- - content_for :illustration do
29
- - if @race.picture_asset
30
- .illustration.thumbs
31
- = image_tag @race.picture_asset.thumbnail(:square)
32
- %span.frame
33
- %p.caption
34
- = @race.picture_asset.caption
35
28
 
36
29
  - content_for :description do
37
30
  = RedCloth.new(@race.description).to_html
@@ -51,9 +44,18 @@
51
44
  %p No checkpoints defined.
52
45
 
53
46
  - content_for :map do
54
- - if @race.map_asset
55
- %h2.map
56
- = link_to "Download map", @race.map_asset.thumbnail('original'), :class => 'racemap'
47
+ - if asset = @race.map_asset
48
+ = link_to image_tag(asset.thumbnail(:square), :class => 'bordered'), asset.thumbnail(:full), :class => "thumbnail", :rel => asset.thumbnail(:original)
49
+ - unless asset.caption.blank?
50
+ %p.caption
51
+ = asset.caption
52
+
53
+ - content_for :illustration do
54
+ - if asset = @race.picture_asset
55
+ = link_to image_tag(asset.thumbnail(:square), :class => 'bordered'), asset.thumbnail(:full), :class => "thumbnail", :rel => asset.thumbnail(:original)
56
+ - unless asset.caption.blank?
57
+ %p.caption
58
+ = asset.caption
57
59
 
58
60
  - content_for :records do
59
61
  %h2.records
@@ -78,7 +80,29 @@
78
80
  - content_for :results do
79
81
  Results:
80
82
  - if @race.instances.with_results.any?
81
- - @race.instances.with_results.each do |instance|
82
- = link_to instance.name, race_instance_url(@race, instance)
83
+ = @race.instances.with_results.map { |instance| link_to instance.name, race_instance_url(@race, instance) }.join(', ') + '.'
83
84
  - else
84
- None yet
85
+ None yet.
86
+
87
+ - content_for :see_also do
88
+ .see_also
89
+ %p
90
+ More races:
91
+ = Race.except(@race).map {|race| link_to race.name, race_url(race) }.join(', ') + '.'
92
+
93
+
94
+
95
+ - content_for :introduction do
96
+ = yield :subtitle
97
+ = yield :results
98
+ %br
99
+ = yield :next
100
+
101
+ - content_for :sidebar do
102
+ = yield :illustration
103
+ = yield :map
104
+
105
+ = yield :description
106
+ = yield :checkpoints
107
+ = yield :records
108
+ = yield :see_also
data/config/routes.rb CHANGED
@@ -10,7 +10,6 @@ ActionController::Routing::Routes.draw do |map|
10
10
  # public interface is read-only and uses slugs for url-friendliness (and seo)
11
11
  map.races '/races', :controller => 'races', :action => 'index'
12
12
  map.race '/races/:slug', :controller => 'races', :action => 'show'
13
- map.results '/results', :controller => 'race_instances', :action => 'index'
14
13
 
15
14
  map.race_instance '/races/:race_slug/:slug', :controller => 'race_instances', :action => 'show'
16
15
  map.race_club '/races/:race_slug/:slug/club/:club', :controller => 'race_instances', :action => 'show'
@@ -45,7 +45,7 @@ class RaceData < ActiveRecord::Migration
45
45
  t.column :site_id, :integer
46
46
  end
47
47
  add_index :race_checkpoints, [:site_id]
48
- add_index :race_checkpoints, [:race_instance_id]
48
+ add_index :race_checkpoints, [:race_id]
49
49
 
50
50
  # clubs, categories and competitors are global
51
51
 
@@ -0,0 +1,9 @@
1
+ class RaceCategory < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :races, :cat, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :races, :cat
8
+ end
9
+ end
@@ -2,7 +2,7 @@
2
2
  # require_dependency 'application_controller'
3
3
 
4
4
  class RaceResultsExtension < Radiant::Extension
5
- version "1.1.1"
5
+ version "1.2.0"
6
6
  description "Makes easy the uploading, analysis and display of race results. Built for fell races but should work for most timed or score events."
7
7
  url "http://spanner.org/radiant/race_results"
8
8
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-race_results-extension}
8
- s.version = "1.1.1"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
12
- s.date = %q{2010-10-05}
12
+ s.date = %q{2011-02-01}
13
13
  s.description = %q{Makes easy the uploading, analysis and display of race results. Built for fell races but should work for most timed or score events including those with checkpoints.}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -65,6 +65,7 @@ Gem::Specification.new do |s|
65
65
  "app/views/race_instances/show.html.haml",
66
66
  "app/views/race_performances/_headings.html.haml",
67
67
  "app/views/race_performances/_performance.html.haml",
68
+ "app/views/races/_standard_parts.html.haml",
68
69
  "app/views/races/index.html.haml",
69
70
  "app/views/races/show.html.haml",
70
71
  "config/routes.rb",
@@ -80,6 +81,7 @@ Gem::Specification.new do |s|
80
81
  "db/migrate/20091228122837_record_holder.rb",
81
82
  "db/migrate/20100106104850_remember_calculations.rb",
82
83
  "db/migrate/20100426104801_race_attachments.rb",
84
+ "db/migrate/20101005112007_race_category.rb",
83
85
  "features/support/env.rb",
84
86
  "features/support/paths.rb",
85
87
  "lib/duration_extensions.rb",
@@ -66,12 +66,23 @@ class RacesDataset < Dataset::Base
66
66
  end
67
67
  end
68
68
  create_race "Scored" do
69
- create_instance "2010", :started_at => DateTime.civil(2008, 10, 6, 9, 0, 0) do
70
- create_checkpoint "Big", :value => 50
71
- create_checkpoint "Small", :value => 10
72
- create_checkpoint "Middling", :value => 25
73
- end
69
+ create_checkpoint "Big", :value => 50
70
+ create_checkpoint "Small", :value => 10
71
+ create_checkpoint "Middling", :value => 25
72
+ create_instance "2010", :started_at => DateTime.civil(2008, 10, 6, 9, 0, 0)
73
+ end
74
+ create_race "Duddon" do
75
+ create_checkpoint "Harter"
76
+ create_checkpoint "Hardknott"
77
+ create_checkpoint "Little Stand"
78
+ create_checkpoint "3 Shires"
79
+ create_checkpoint "Swirl How"
80
+ create_checkpoint "Dow Crag"
81
+ create_checkpoint "White Pike"
82
+ create_checkpoint "Caw"
83
+ create_instance "2010"
74
84
  end
85
+
75
86
  end
76
87
 
77
88
  helpers do
@@ -1,4 +1,4 @@
1
- Pos,Name,Club,Cat,Harter,Hardknott,L Stand,3 Shires,Swirl How,Dow Crag,White Pike,Caw,Finish
1
+ Pos,Name,Club,Cat,Harter,Hardknott,Little Stand,3 Shires,Swirl How,Dow Crag,White Pike,Caw,Finish
2
2
  1,Simon Booth,Borrowdale,M40,0:36:30,0:56:12,1:21:17,1:35:22,1:58:52,2:16:01,2:27:58,2:44:09,2:52:31
3
3
  2,Pete Vale,Mercia,M,0:36:16,0:56:09,1:21:25,1:36:18,2:00:44,2:18:52,2:30:52,2:48:15,2:57:43
4
4
  3,Jim Davies,Borrowdale,M40,0:36:36,0:56:23,1:21:58,1:37:09,2:00:45,2:18:54,2:30:53,2:47:57,2:58:26
@@ -55,50 +55,56 @@ describe RaceInstance do
55
55
  end
56
56
  end
57
57
 
58
- it "should import correctly a results file with checkpoints" do
59
- @race = Race.create(:name => "Long Duddon", :slug => 'long_duddon')
60
- @ri = @race.instances.new({
61
- :name => '2008',
62
- :slug => '2008'
63
- })
64
- @ri.save!
65
- @ri.should_receive(:read_results_file).and_return(CSV.read(File.dirname(__FILE__) + '/../files/long_duddon_2008.csv'))
66
- @ri.send :process_results_file
67
-
68
- @ri.performances.any?.should be_true
69
- @ri.performances.count.should == 229
70
- perf = @ri.winning_performance
71
- perf.competitor.should == RaceCompetitor.find_by_name("Simon Booth")
72
- perf.elapsed_time.should == "2:52:31"
73
- perf.position.should == 1
74
- perf.status_id.should == 100
75
- perf.status.should == RacePerformanceStatus['Finished']
76
-
77
- perf.checkpoint_times.any?.should be_true
78
- cp = @ri.checkpoints.first
79
- cp.name.should == 'Harter'
80
- perf.time_at(cp).elapsed_time.should == "0:36:30"
81
-
82
- @ri.categories.any?.should be_true
83
- @ri.categories.include?(race_categories(:mv40)).should be_true
84
- @ri.winner('MV40').should == RaceCompetitor.find_by_name("Simon Booth")
85
- @ri.winner('MV50').should == RaceCompetitor.find_by_name("David Spedding")
86
- @ri.winner('MV60').should == RaceCompetitor.find_by_name("David Spedding")
87
-
88
- # p " L: #{RaceCategory.find_by_name('L').inspect}"
89
- # p " LV40: #{RaceCategory.find_by_name('LV40').inspect}"
90
- #
91
- # categories = RaceCategory.within("LV40")
92
- # p " categories in LV40 and above: #{categories.map(&:name).to_sentence}"
93
- #
94
- # exact = @ri.performances.in_category("LV40")
95
- # p " performances in LV40: #{exact.inspect}"
96
- #
97
- # eligible = @ri.performances.eligible_for_category("LV40")
98
- # p " performances in LV40 and above: #{eligible.inspect}"
58
+ describe "importing results from a file with checkpoints" do
59
+ before do
60
+ @race = races(:duddon)
61
+ @cp = @race.checkpoints.find_by_name("Harter")
62
+ @ri = @race.in(2010)
63
+ @ri.stub!(:read_results_file).and_return(CSV.read(File.dirname(__FILE__) + '/../files/long_duddon_2008.csv'))
64
+ @ri.send :process_results_file
65
+ @perf = @ri.winning_performance
66
+ end
67
+
68
+ it "should import performances" do
69
+ @ri.performances.any?.should be_true
70
+ @ri.performances.count.should == 229
71
+ @perf.competitor.should == RaceCompetitor.find_by_name("Simon Booth")
72
+ @perf.elapsed_time.should == "2:52:31"
73
+ @perf.position.should == 1
74
+ @perf.status_id.should == 100
75
+ @perf.status.should == RacePerformanceStatus['Finished']
76
+ end
99
77
 
100
- @ri.winner('LV40').should == RaceCompetitor.find_by_name("Helene Whitaker")
101
- @ri.winner('L').should == RaceCompetitor.find_by_name("Janet McIver")
78
+ it "should import checkpoint times" do
79
+ @perf.checkpoint_times.any?.should be_true
80
+ Rails.logger.warn ">>>"
81
+ p "checkpoint is #{@cp.inspect}"
82
+ p "checkpoint times are #{@perf.checkpoint_times.inspect}"
83
+ p "perf.time_at(@cp) is #{@perf.time_at(@cp).inspect}"
84
+ Rails.logger.warn "<<<"
85
+ @perf.time_at(@cp).elapsed_time.should == "0:36:30"
86
+ end
87
+
88
+ it "should import categories and notice category winners" do
89
+ @ri.categories.any?.should be_true
90
+ @ri.categories.include?(race_categories(:mv40)).should be_true
91
+ @ri.winner('MV40').should == RaceCompetitor.find_by_name("Simon Booth")
92
+ @ri.winner('MV50').should == RaceCompetitor.find_by_name("David Spedding")
93
+ @ri.winner('MV60').should == RaceCompetitor.find_by_name("David Spedding")
94
+ # p " L: #{RaceCategory.find_by_name('L').inspect}"
95
+ # p " LV40: #{RaceCategory.find_by_name('LV40').inspect}"
96
+ #
97
+ # categories = RaceCategory.within("LV40")
98
+ # p " categories in LV40 and above: #{categories.map(&:name).to_sentence}"
99
+ #
100
+ # exact = @ri.performances.in_category("LV40")
101
+ # p " performances in LV40: #{exact.inspect}"
102
+ #
103
+ # eligible = @ri.performances.eligible_for_category("LV40")
104
+ # p " performances in LV40 and above: #{eligible.inspect}"
105
+ @ri.winner('LV40').should == RaceCompetitor.find_by_name("Helene Whitaker")
106
+ @ri.winner('L').should == RaceCompetitor.find_by_name("Janet McIver")
107
+ end
102
108
  end
103
109
 
104
110
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-race_results-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-05 00:00:00 +01:00
18
+ date: 2011-02-01 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,7 @@ files:
106
106
  - app/views/race_instances/show.html.haml
107
107
  - app/views/race_performances/_headings.html.haml
108
108
  - app/views/race_performances/_performance.html.haml
109
+ - app/views/races/_standard_parts.html.haml
109
110
  - app/views/races/index.html.haml
110
111
  - app/views/races/show.html.haml
111
112
  - config/routes.rb
@@ -121,6 +122,7 @@ files:
121
122
  - db/migrate/20091228122837_record_holder.rb
122
123
  - db/migrate/20100106104850_remember_calculations.rb
123
124
  - db/migrate/20100426104801_race_attachments.rb
125
+ - db/migrate/20101005112007_race_category.rb
124
126
  - features/support/env.rb
125
127
  - features/support/paths.rb
126
128
  - lib/duration_extensions.rb