-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
140 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ table.profile { | |
} | ||
} | ||
|
||
form.profile_form { | ||
form.resume_form { | ||
textarea { | ||
width: 80%; | ||
height: 24em; | ||
|
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
class UserResumesController < ApplicationController | ||
before_action :set_user_and_resume | ||
|
||
respond_to :html | ||
layout 'users' | ||
|
||
def new | ||
if @user_resume.present? | ||
redirect_to edit_users_resume_path | ||
else | ||
@user_resume = UserResume.new(user_id: @user.id) | ||
end | ||
end | ||
|
||
def edit | ||
unless @user_resume.present? | ||
redirect_to new_users_resume_path | ||
end | ||
end | ||
|
||
def create | ||
@user_resume = UserResume.new(user_id: @user.id, body: user_resume_params[:body]) | ||
@user_resume.save | ||
flash[:notice] = 'Resume created.' | ||
redirect_to home_path(@user.nick) | ||
end | ||
|
||
def update | ||
@user_resume.update_attributes(body: user_resume_params[:body]) | ||
flash[:notice] = 'Resume updated.' | ||
redirect_to home_path(@user.nick) | ||
end | ||
|
||
private | ||
|
||
def set_user_and_resume | ||
redirect_to(root_path) and return unless view_context.myself?(current_user) | ||
@user = current_user | ||
@user_resume = current_user.resume | ||
end | ||
|
||
def user_resume_params | ||
params.require(:user_resume).permit(:user_id, :body) | ||
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class UserProfile < ActiveRecord::Base | ||
class UserResume < ActiveRecord::Base | ||
belongs_to :user | ||
include Renderable | ||
end |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
%div | ||
= form_for @user_resume, url: { controller: :user_resumes, action: form_action } , html: { class: 'resume_form' } do |f| | ||
.field | ||
= f.text_area :body | ||
= f.hidden_field :user_id | ||
.actions | ||
= button_tag class: 'pure-button' do | ||
%i.fa.fa-save.fa-lg | ||
Save |
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,7 @@ | ||
class RenameProfileToResume < ActiveRecord::Migration | ||
def change | ||
if table_exists?(:user_profiles) | ||
rename_table(:user_profiles, :user_resumes) | ||
end | ||
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 was deleted.
Oops, something went wrong.
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,41 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe UserResumesController, type: :controller do | ||
let(:resume) { create(:user_resume) } | ||
|
||
describe '#new' do | ||
subject(:new_resume) { get :new } | ||
|
||
context 'when user does not login' do | ||
it { expect(new_resume).to redirect_to root_path } | ||
end | ||
|
||
context 'when login user without resume' do | ||
before { sign_in create(:user) } | ||
it { expect(new_resume).to be_ok } | ||
end | ||
|
||
context 'when login user with resume' do | ||
before { sign_in resume.user } | ||
it { expect(new_resume).to redirect_to edit_users_resume_path } | ||
end | ||
end | ||
|
||
describe '#edit' do | ||
subject(:new_resume) { get :edit } | ||
|
||
context 'when user does not login' do | ||
it { expect(new_resume).to redirect_to root_path } | ||
end | ||
|
||
context 'when login user without resume' do | ||
before { sign_in create(:user) } | ||
it { expect(new_resume).to redirect_to new_users_resume_path } | ||
end | ||
|
||
context 'when login user with resume' do | ||
before { sign_in resume.user } | ||
it { expect(new_resume).to be_ok } | ||
end | ||
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 was deleted.
Oops, something went wrong.
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,6 @@ | ||
FactoryGirl.define do | ||
factory :user_resume do | ||
user | ||
body "User Resume Body" | ||
end | ||
end |