Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/gtfs/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module GTFS
class Route
include GTFS::Model

has_required_attrs :id, :short_name, :long_name, :type
has_optional_attrs :agency_id, :desc, :url, :color, :text_color
has_required_attrs :id, :type
has_optional_attrs :agency_id, :desc, :url, :color, :text_color, :short_name, :long_name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should clear the merge conflict.

Suggested change
has_optional_attrs :agency_id, :desc, :url, :color, :text_color, :short_name, :long_name
has_optional_attrs :agency_id, :desc, :url, :color, :text_color, :sort_order, :short_name, :long_name

attr_accessor *attrs

column_prefix :route_
Expand All @@ -15,5 +15,9 @@ class Route
def self.parse_routes(data, options={})
return parse_models(data, options)
end

def valid?
super && ! (short_name || long_name).nil?
end
end
end
21 changes: 21 additions & 0 deletions spec/gtfs/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,26 @@
subject {GTFS::Route.parse_routes(source_text, opts)}

include_examples 'models'

context '#valid' do
let(:opts) {{}}
let(:source_text) {header_line + valid_line}

context 'routes with only short name' do
let(:valid_line) {"4679,1,001,,,3,,0000FF,FFFFFF\n"}

it "are valid" do
subject.first.valid?.should == true
end
end

context 'routes with only long name' do
let(:valid_line) {"4679,1,,SINAI - FORT McHENRY,,3,,0000FF,FFFFFF\n"}

it "are valid" do
subject.first.valid?.should == true
end
end
end
end
end