Last active
August 29, 2015 13:55
-
-
Save Stenerson/8731511 to your computer and use it in GitHub Desktop.
How I do seeds (circa 2013)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Running Seeds | |
# From console (for development/production environmnts) | |
# $ rake db:seed | |
# Seeding tests (rspec) | |
# Create helper method | |
def load_seed_data | |
load "#{Rails.root}/db/seeds.rb" | |
end | |
# Call in before or it blocks | |
describe "something" do | |
before { load_seed_data } | |
it { should do_something } | |
end | |
it "adds the user as a project owner" do | |
load_seed_data | |
click_button "Create Project" | |
expect(user.project_role(Project.last)).to eql(ProjectRole.first) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Statuses | |
['Not Started', 'In Progress', 'On Hold', 'Complete', 'Not Applicable','Closed'].each do |status| | |
Status.find_or_create_by(status: status) | |
end | |
#Types | |
['Enhancement', 'Bug', 'Proposal'].each do |type| | |
Type.find_or_create_by(name: type) | |
end | |
#Severities | |
['Trivial','Minor', 'Major', 'Show Stopper'].each do |severity| | |
Severity.find_or_create_by(name: severity) | |
end | |
#Project Roles | |
['Owner','Collaborator','Viewer','No Access'].each do |role| #Use "No Access" for temporary disabling | |
ProjectRole.find_or_create_by(name: role) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment