Skip to content

Commit

Permalink
Merge branch 'release/0.11.13.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Jan 11, 2017
2 parents 485e896 + 4b92e69 commit e9f1141
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class User < ActiveRecord::Base
dependent: :destroy
has_many :logged_actions
has_many :subscriptions, as: :receiver, dependent: :destroy
has_many :comments, dependent: :destroy
has_and_belongs_to_many :teams

validates :email, email: true,
Expand All @@ -22,7 +23,6 @@ class User < ActiveRecord::Base
allow_blank: true
validates :last_name, human_name: true,
allow_blank: true
has_many :comments, dependent: :destroy

extend Enumerize
enumerize :role, in: [ :user, :admin, :author, :tech_admin ], default: :user
Expand Down
19 changes: 19 additions & 0 deletions bin/data_fixes/user_to_member_fix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if ARGV.count == 2
user = User.find ARGV[0]
member = Member.find ARGV[1]
puts "Updating associations...".green
[:authentications, :article, :registrations, :logged_actions, :comments].each do |association|
user.send(association).each do |obj|
obj.update_attributes! user_id: member.id
end
end
user.subscriptions.each { |s| s.update_attributes! receiver_id: member.id }
puts "Updating attributes...".green
[:password_digest, :role, :state, :token, :email].each do |attribute|
member.update_attributes! attribute => user.send(attribute)
end
puts "Destroy old user...".green
user.destroy
else
raise 'You should arguments: user.id, member.id'
end
6 changes: 4 additions & 2 deletions bin/development_data_fixes/one_password_to_all.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
password = User.first.password_digest
User.update_all password_digest: password
if Rails.env.development?
password = User.first.password_digest
User.update_all password_digest: password
end
1 change: 1 addition & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ if ARGV.include? 'prod'
system "dropdb ulmic_test --if-exists && createdb ulmic_test && pg_restore -d ulmic_test tmp/test.dump"
system 'DB=prod bundle exec tconsole'
else
system 'RAILS_ENV=test rake db:drop db:create db:migrate'
system 'DB=empty bundle exec tconsole'
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "state"
end

create_table "activity_lines_lider_ya_lider_participations", force: :cascade do |t|
t.integer "participant_id"
t.integer "stage_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "state"
end

create_table "activity_lines_lider_ya_lider_stages", force: :cascade do |t|
Expand Down Expand Up @@ -470,6 +470,9 @@
t.integer "user_id"
end

add_index "teams_users", ["team_id"], name: "index_teams_users_on_team_id", using: :btree
add_index "teams_users", ["user_id"], name: "index_teams_users_on_user_id", using: :btree

create_table "test_paper_questions", force: :cascade do |t|
t.text "text"
t.integer "test_paper_id"
Expand Down
2 changes: 1 addition & 1 deletion test/factories/members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
email
patronymic { generate :human_name }
motto { generate :string }
ticket { Member.where.not(ticket: nil).order(:ticket).last.ticket + 1 }
ticket { Member.where.not(ticket: nil).any? ? Member.where.not(ticket: nil).order(:ticket).last.ticket + 1 : generate(:integer) }
parent_id { Member.last ? Member.last.id : nil }
mobile_phone { generate :phone }
birth_date { generate :datetime }
Expand Down

0 comments on commit e9f1141

Please sign in to comment.