Commit 8aa4819c2f0e9f89ff0975410b726cb2e35600cc
Exists in
colab
and in
4 other branches
Merge pull request #256 from mezuro/configurations_seed
Added seeds script to set the default configurations to public
Showing
4 changed files
with
30 additions
and
4 deletions
Show diff stats
db/seeds.rb
... | ... | @@ -5,3 +5,22 @@ |
5 | 5 | # |
6 | 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) |
7 | 7 | # Mayor.create(name: 'Emanuel', city: cities.first) |
8 | + | |
9 | +# Default mezuro user, the owner of the public kalibro configurations | |
10 | +password = Devise.friendly_token | |
11 | +default_user = FactoryGirl.create(:mezuro_user, password: password) | |
12 | + | |
13 | +puts "-- Default user created:" | |
14 | +puts " Email: #{default_user.email}" | |
15 | +puts " Password: #{password}" | |
16 | + | |
17 | +# The database should have only the default public | |
18 | +# configurations when this file is executed | |
19 | +kalibro_configurations = KalibroConfiguration.all | |
20 | +kalibro_configurations.each do |configuration| | |
21 | + attributes = KalibroConfigurationAttributes.new | |
22 | + attributes.kalibro_configuration_id = configuration.id | |
23 | + attributes.public = true | |
24 | + attributes.user_id = default_user.id | |
25 | + attributes.save | |
26 | +end | ... | ... |
spec/controllers/users_controller_spec.rb
... | ... | @@ -2,7 +2,7 @@ require 'rails_helper' |
2 | 2 | |
3 | 3 | describe UsersController, :type => :controller do |
4 | 4 | describe 'projects' do |
5 | - let(:user) { FactoryGirl.build(:user) } | |
5 | + let(:user) { FactoryGirl.build(:user, :with_id) } | |
6 | 6 | |
7 | 7 | before :each do |
8 | 8 | User.expects(:find).with(user.id).returns(user) | ... | ... |
spec/factories/users.rb
... | ... | @@ -2,16 +2,23 @@ |
2 | 2 | |
3 | 3 | FactoryGirl.define do |
4 | 4 | factory :user do |
5 | - id 1 | |
6 | 5 | name "Diego Martinez" |
7 | 6 | email "diego@email.com" |
8 | 7 | password "password" |
9 | 8 | |
10 | 9 | factory :another_user do |
11 | - id 2 | |
12 | 10 | name "Heitor Reis" |
13 | 11 | email "hr@email.com" |
14 | 12 | password "password" |
15 | 13 | end |
14 | + | |
15 | + factory :mezuro_user do | |
16 | + name "Mezuro Default user" | |
17 | + email "mezuro@librelist.com" | |
18 | + end | |
19 | + | |
20 | + trait :with_id do | |
21 | + sequence(:id, 1) | |
22 | + end | |
16 | 23 | end |
17 | 24 | end | ... | ... |
spec/models/reading_group_spec.rb
... | ... | @@ -76,7 +76,7 @@ describe ReadingGroup, :type => :model do |
76 | 76 | |
77 | 77 | describe 'class methods' do |
78 | 78 | describe 'public_or_owned_by_user' do |
79 | - let!(:user) { FactoryGirl.build(:user) } | |
79 | + let!(:user) { FactoryGirl.build(:user, :with_id) } | |
80 | 80 | |
81 | 81 | let!(:owned_private_attrs) { FactoryGirl.build(:reading_group_attributes, :private, user_id: user.id) } |
82 | 82 | let!(:owned_public_attrs) { FactoryGirl.build(:reading_group_attributes, user_id: user.id) } | ... | ... |