Skip to content

Commit

Permalink
Add new valid fightpost can save test, need below PR to merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Mar 20, 2016
1 parent f98b75d commit c973133
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@

create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.integer "taggable_id"
t.string "tagger_type"
t.integer "tagger_id"
t.string "context", limit: 128
t.datetime "created_at"
end
Expand Down
8 changes: 4 additions & 4 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

99.times do |n|
name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org"
email = "example-#{n + 1}@railstutorial.org"
User.create!(name: name,
email: email,
password: 'password',
Expand All @@ -24,9 +24,9 @@
users = User.order(:created_at).take(6)
50.times do
content = Faker::Lorem.sentence(5)
tag = ['Aikido', 'Karate', 'Taekwondo', 'Thai boxing', 'Boxing', 'Tai Chi', 'Sanda', 'Kendo',
'Wing Chun', 'Judo', '八极拳'].sample
users.each { |user| user.fightposts.create!(content: content, tag_list: tag) }
tag_list = ['Aikido', 'Karate', 'Taekwondo', 'Thai boxing', 'Boxing', 'Tai Chi', 'Sanda', 'Kendo',
'Wing Chun', 'Judo', '八极拳']
users.each { |user| user.fightposts.create!(content: content, tag_list: tag_list.sample) }
end

# Following relationships
Expand Down
7 changes: 6 additions & 1 deletion test/models/fightpost_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class FightpostTest < ActiveSupport::TestCase
def setup
@user = users(:michael)
@fightpost = @user.fightposts.build(content: 'aikido')
@fightpost = @user.fightposts.build(content: 'aikido', tag_list: 'Aikido')
end

test 'should be valid' do
Expand All @@ -25,6 +25,11 @@ def setup
assert_not @fightpost.valid?
end

test 'valid fightpost can save' do
@fightpost.save!
assert_not @fightpost.new_record?
end

test 'order should be most recent first' do
assert_equal Fightpost.first, fightposts(:most_recent)
end
Expand Down

0 comments on commit c973133

Please sign in to comment.