generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #549 from ita-social-projects/fix/user_attributes_…
…null fix/user_attrbutes_null
- Loading branch information
Showing
10 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class ChangeUserAttributesNull < ActiveRecord::Migration[6.1] | ||
def up | ||
User.where(first_name: nil).each do |user| | ||
user.update(first_name: "Firstname") | ||
user.save(validate: false) | ||
end | ||
|
||
User.where(last_name: nil).each do |user| | ||
user.update(last_name: "Lastname") | ||
user.save(validate: false) | ||
end | ||
|
||
change_column_null :users, :first_name, false | ||
change_column_null :users, :last_name, false | ||
end | ||
|
||
def down | ||
change_column_null :users, :first_name, true | ||
change_column_null :users, :last_name, true | ||
end | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,24 @@ | |
|
||
RSpec.describe UsersCsvGenerator do | ||
let(:time_login) { Time.new(2020, 0o1, 0o1).utc } | ||
|
||
let(:users) do | ||
[create(:user, email: "[email protected]", last_sign_in_at: time_login)] | ||
[create(:user, email: "[email protected]", first_name: "Han", last_name: "Solo", last_sign_in_at: time_login)] | ||
end | ||
|
||
let(:csv_content) do | ||
result = "email,first_name,last_name,last_sign_in_at\n" | ||
|
||
users.each do |user| | ||
result += "#{users.first.email},#{users.first.first_name},#{users.first.last_name},#{time_login}\n" | ||
end | ||
|
||
result | ||
end | ||
|
||
it "export users" do | ||
expect(UsersCsvGenerator.call(users, | ||
fields: ["email", "last_sign_in_at"])) | ||
.to eq("email,last_sign_in_at\n[email protected],#{time_login}\n") | ||
fields: ["email", "first_name", "last_name", "last_sign_in_at"])) | ||
.to eq(csv_content) | ||
end | ||
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
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