Skip to content

Commit 5d17929

Browse files
committed
fix tests
1 parent c604912 commit 5d17929

File tree

9 files changed

+408
-394
lines changed

9 files changed

+408
-394
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ source 'https://rubygems.org' do
139139

140140
group :development, :test do
141141
gem 'annotate'
142+
gem 'fabrication', '2.11.3'
142143
gem 'fabrication-rails'
143144
gem 'ffaker'
144145
gem 'launchy'

Gemfile.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ GEM
177177
eventmachine (1.0.7)
178178
excon (0.45.3)
179179
execjs (2.5.2)
180-
fabrication (2.13.2)
180+
fabrication (2.11.3)
181181
fabrication-rails (0.0.1)
182182
fabrication
183183
railties (>= 3.0)
@@ -762,6 +762,7 @@ DEPENDENCIES
762762
dotenv-rails!
763763
elasticsearch-model!
764764
elasticsearch-rails!
765+
fabrication (= 2.11.3)!
765766
fabrication-rails!
766767
faraday!
767768
feedjira!

app/models/invitation.rb

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
#
1515

1616
class Invitation < ActiveRecord::Base
17+
belongs_to :team
18+
belongs_to :inviter, class_name: 'User'
1719
end

app/models/opportunity.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Opportunity < ActiveRecord::Base
3737

3838
OPPORTUNITY_TYPES = %w(full-time part-time contract internship)
3939

40-
has_many :seized_opportunities
40+
has_many :seized_opportunities, dependent: :delete_all
4141

4242
# Order here dictates the order of validation error messages displayed in views.
4343
validates :name, presence: true, allow_blank: false
@@ -98,7 +98,7 @@ def update_cached_tags
9898
end
9999

100100
def seize_by(user)
101-
seized_opportunities.create!(user_id: user.id, team_id: team_id)
101+
seized_opportunities.create!(user_id: user.id)
102102
end
103103

104104
def seized_by?(user)

app/models/protip.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class Protip < ActiveRecord::Base
9595

9696
after_validation :tag_user
9797
before_create :assign_random_id
98+
before_create do
99+
self.user_name = user.name
100+
end
98101
before_save :process_links
99102
before_save :recalculate_score!
100103

@@ -485,7 +488,8 @@ def to_public_hash
485488
link: link,
486489
created_at: created_at,
487490
featured: featured,
488-
user: user_hash
491+
user: user_hash,
492+
user_name: user_name
489493
}
490494
end
491495

app/models/protip/search_wrapper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def initialize(item)
66
end
77

88
def username
9-
item[:user][:username]
9+
item[:user][:name]
1010
end
1111

1212
def profile_url

app/models/team.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class Team < ActiveRecord::Base
9797
has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :delete_all
9898
has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :delete_all
9999
has_many :member_accounts, through: :members, source: :user, class_name: 'User'
100+
has_many :opportunities, dependent: :destroy
101+
has_many :invitations, dependent: :delete_all
100102
has_one :account, class_name: 'Teams::Account', foreign_key: 'team_id', dependent: :delete
101103

102104
accepts_nested_attributes_for :locations, :links, allow_destroy: true, reject_if: :all_blank
@@ -740,9 +742,7 @@ def reindex_search
740742
end
741743

742744
def remove_dependencies
743-
[FollowedTeam, Invitation, Opportunity, SeizedOpportunity].each do |klass|
744-
klass.where(team_id: self.id.to_s).delete_all
745-
end
745+
FollowedTeam.where(team_id: self.id.to_s).delete_all
746746
User.where(team_id: self.id.to_s).update_all('team_id = NULL')
747747
end
748748

0 commit comments

Comments
 (0)