Skip to content

Commit

Permalink
Merge pull request #3018 from fjordllc/feature/select-course-in-signup
Browse files Browse the repository at this point in the history
サインアップ時にURLでコースを指定できるようにした
  • Loading branch information
komagata authored Jul 23, 2021
2 parents eb266c5 + 697ae5c commit 354e16c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def new
when 'trainee'
@user.trainee = true
end
@user.course_id = params[:course_id]
@user.company_id = params[:company_id]
end

def create
@user = User.new(user_params)
@user.course = Course.first

@user.course_id ||= Course.first.id
@user.free = true if @user.trainee?

if @user.staff? || @user.trainee?
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
= f.hidden_field :adviser
= f.hidden_field :trainee
= f.hidden_field :company_id
= f.hidden_field :course_id
= hidden_field_tag :idempotency_token, SecureRandom.uuid
= render 'errors', object: user
.form__items
Expand All @@ -20,7 +21,6 @@
= render 'users/form/description', f: f, user: user
= render 'users/form/tags', f: f, user: user
- unless user.adviser?
= render 'users/form/course', f: f
= render 'users/form/job', f: f
= render 'users/form/os', f: f
= render 'users/form/prefecture', f: f
Expand Down
22 changes: 22 additions & 0 deletions test/system/sign_up_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,28 @@ class SignUpTest < ApplicationSystemTestCase
assert_equal User.find_by(email: email).company_id, companies(:company2).id
end

test 'sign up as trainee with course_id' do
course = courses(:course2)
visit "/users/new?role=trainee&course_id=#{course.id}"

email = 'fuyuko@example.com'

within 'form[name=user]' do
fill_in 'user[login_name]', with: 'foo'
fill_in 'user[email]', with: email
fill_in 'user[name]', with: 'テスト ふゆこ'
fill_in 'user[name_kana]', with: 'テスト フユコ'
fill_in 'user[description]', with: 'テストふゆこです。'
fill_in 'user[password]', with: 'testtest'
fill_in 'user[password_confirmation]', with: 'testtest'
select '学生', from: 'user[job]'
select 'Mac(Intel)', from: 'user[os]'
select '未経験', from: 'user[experience]'
end
click_button '利用規約に同意して参加する'
assert_equal User.find_by(email: email).course_id, course.id
end

test 'sign up with empty description ' do
visit '/users/new'
within 'form[name=user]' do
Expand Down

0 comments on commit 354e16c

Please sign in to comment.