Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeds #838

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Seeds #838

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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ group :development, :test do
gem "launchy", "~> 2.4.2"
gem "minitest", "~> 4.2.0"
gem "quiet_assets", "~> 1.0.0"
gem "ffaker"
end

group :test do
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ GEM
fabrication (1.2.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
ffaker (2.0.0)
ffi (1.9.3)
fssm (0.2.10)
haml (3.1.8)
Expand Down Expand Up @@ -302,6 +303,7 @@ DEPENDENCIES
draper (~> 0.11.1)
exceptional (~> 2.0.32)
fabrication (~> 1.2.0)
ffaker
haml (~> 3.1.4)
haml-rails (~> 0.3.4)
i18n (~> 0.6.0)
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ secret from Twitter. Here are the steps to do that:

Now you should be able to sign in to your development version with Twitter!

### Adding sample data

While developing you can seed your database with a sample data:

$ bundle exec rake db:seed

Default user credentials:

username: johndoe
password: password

### Running the tests

To run the tests you may want to make use of `bundle exec` so you don't get
Expand Down
2 changes: 2 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
seed_file = "#{Rails.root}/db/seeds/#{Rails.env}.rb"
require seed_file if File.exists?(seed_file)
26 changes: 26 additions & 0 deletions db/seeds/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include FFaker

author_john = Author.create(username: 'johndoe', name: 'John Doe', password: 'password', domain: 'localhost:3000',
email: '[email protected]', image_url: 'http://robohash.org/johndoe.png?size=300x300')
user_john = User.create(username: 'johndoe', password: 'password', author: author_john, admin: true, email: '[email protected]')
Admin.create(multiuser: true)

5.times do
name = Name.name
username = name.downcase.gsub(/\.|\s/, '')
password = Internet.password
domain = Internet.domain_name
email = Internet.email
author = Author.create(username: username, name: name, password: password, domain: domain, email: email,
image_url: "http://robohash.org/#{username}.png?size=300x300")
User.create(username: username, password: password, author: author, email: email)
end

authors = Author.all
authors.each { |a| Feed.create(author: authors.sample) }

100.times do |n|
Update.create(author: authors.sample,
text: n%10 == 0 ? '@johndoe ' + Lorem.sentence : Lorem.sentence,
feed: Feed.first)
end