Sha256: 2237e6919b31e6851f54970073a5630ac66d9bda3b3b1ef0364b082f3746a925

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

# coding: utf-8
# This file is seed file for test data on development environment.

ActivityNotification::Notification.delete_all
Comment.delete_all
Article.delete_all
Admin.delete_all
User.delete_all
ActivityNotification::Notification.connection.execute("UPDATE sqlite_sequence SET seq = 0;")

['Ichiro', 'Stephen', 'Klay', 'Kevin'].each do |name|
  user = User.new(
    email:                 "#{name.downcase}@example.com",
    password:              'changeit',
    password_confirmation: 'changeit',
    name:                  name,
  )
  user.skip_confirmation!
  user.save!
end

['Ichiro'].each do |name|
  user = User.find_by_name(name)
  Admin.create(user: user)
end

User.all.each do |user|
  article = user.articles.create(
    title: "#{user.name}'s first article",
    body:  "This is the first #{user.name}'s article. Please read it!"
  )
  article.notify :users, send_email: false
end

Article.all.each do |article|
  User.all.each do |user|
    comment = article.comments.create(
      user: user,
      body:  "This is the first #{user.name}'s comment to #{article.user.name}'s article."
    )
    comment.notify :users, send_email: false
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activity_notification-1.1.0 spec/rails_app/db/seeds.rb
activity_notification-1.0.2 spec/rails_app/db/seeds.rb
activity_notification-1.0.1 spec/rails_app/db/seeds.rb
activity_notification-1.0.0 spec/rails_app/db/seeds.rb