Skip to content

Commit

Permalink
new relations for receivers and tags to district
Browse files Browse the repository at this point in the history
Signed-off-by: evizitei <ethan.vizitei@gmail.com>
  • Loading branch information
evizitei committed Oct 24, 2010
1 parent d5505aa commit ca8b056
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/district.rb
@@ -1,4 +1,6 @@
class District < ActiveRecord::Base
has_many :users
has_many :stations
has_many :receivers
has_many :tags
end
1 change: 1 addition & 0 deletions app/models/receiver.rb
@@ -1,5 +1,6 @@
class Receiver < ActiveRecord::Base
belongs_to :station
belongs_to :district
has_many :receiver_staffing_records

def tag_arriving!(tag_sig)
Expand Down
1 change: 1 addition & 0 deletions app/models/tag.rb
@@ -1,4 +1,5 @@
class Tag < ActiveRecord::Base
belongs_to :district
has_many :staffing_records
has_many :receiver_staffing_records
end
8 changes: 8 additions & 0 deletions spec/models/district_spec.rb
Expand Up @@ -8,4 +8,12 @@
it "has many stations" do
District.new.stations.should eq([])
end

it "has many tags" do
District.new.tags.should eq([])
end

it "has many receivers" do
District.new.receivers.should eq([])
end
end
17 changes: 17 additions & 0 deletions spec/models/receiver_spec.rb
Expand Up @@ -7,6 +7,23 @@
receiver.station.should == station
end

it "belongs to a district" do
district = Factory(:district)
receiver = Factory(:receiver,:district=>district)
receiver.district.should == district
end

it "should update the district when the station changes" do
district = Factory(:district)
station = Factory(:station,:district=>district)
receiver = Factory(:receiver)
receiver.station = station
receiver.save
receiver.reload
receiver.station.should == station
receiver.district.should == district
end

it "has many staffing records" do
Receiver.new.receiver_staffing_records.should == []
end
Expand Down
4 changes: 4 additions & 0 deletions spec/models/tag_spec.rb
Expand Up @@ -13,4 +13,8 @@
it "has many receiver_staffing_records" do
Tag.new.receiver_staffing_records.should eq([])
end

it "belongs to a district" do
Tag.new.district.should == nil
end
end

0 comments on commit ca8b056

Please sign in to comment.