-
Notifications
You must be signed in to change notification settings - Fork 0
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 #69 from Code-the-Dream-School/68_fix_profil_page
complete user profile page
- Loading branch information
Showing
9 changed files
with
176 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeDefaultForBioInUsers < ActiveRecord::Migration[6.0] | ||
def change | ||
change_column_default :users, :bio, nil | ||
end | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
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,50 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "Users", type: :request do | ||
let!(:user) { create(:user, bio: nil, profile_picture: Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/default.png'), 'image/png')) } | ||
|
||
let(:valid_attributes) do | ||
{ | ||
bio: Faker::Lorem.sentence, | ||
profile_picture: Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/default.png'), 'image/png') | ||
} | ||
end | ||
|
||
let(:invalid_attributes) do | ||
{ | ||
bio: nil, | ||
profile_picture: nil | ||
} | ||
end | ||
|
||
describe "GET /edit" do | ||
it "returns a successful response" do | ||
sign_in user | ||
get edit_user_registration_path | ||
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
|
||
describe "PATCH /update" do | ||
context "with valid parameters" do | ||
it "updates the user's bio and profile picture" do | ||
sign_in user | ||
patch user_registration_path, params: { user: valid_attributes } | ||
user.reload | ||
expect(user.bio).to eq(valid_attributes[:bio]) | ||
expect(user.profile_picture).to be_attached | ||
end | ||
end | ||
|
||
context "with invalid parameters" do | ||
it "does not update the user and re-renders the edit template" do | ||
sign_in user | ||
patch user_registration_path, params: { user: invalid_attributes } | ||
user.reload | ||
expect(user.bio).to be_nil | ||
expect(user.profile_picture.filename).to eq('default.png') | ||
expect(response.body).to include('error') | ||
end | ||
end | ||
end | ||
end |