Skip to content

Commit

Permalink
Add domain to company (#140)
Browse files Browse the repository at this point in the history
We need to store the domain wanted by the company to redirect to its job pages after entering DOMAIN.openjobs.me.
  • Loading branch information
rafaelsevla authored and duduribeiro committed Oct 29, 2018
1 parent 4a875d4 commit 2a83e38
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class UsersController < Clearance::UsersController
private

def user_params
params.require(:user).permit(:email, :password, company_attributes: %i[name url])
params.require(:user).permit(:email, :password, company_attributes: %i[name url domain])
end
end
1 change: 1 addition & 0 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
<%= form.fields_for :company, @user.company || @user.build_company do |company_form| %>
<%= company_form.text_field :name, class: 'field', placeholder: Company.human_attribute_name(:name) %>
<%= company_form.text_field :url, class: 'field', placeholder: Company.human_attribute_name(:url) %>
<%= company_form.text_field :domain, class: 'field', placeholder: Company.human_attribute_name(:domain) %>
<% end %>
1 change: 1 addition & 0 deletions config/locales/activerecord.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ en:
company:
name: Company name
url: Company website
domain: Custom domain
1 change: 1 addition & 0 deletions config/locales/activerecord.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ pt-BR:
company:
name: Nome da Empresa
url: Site da Empresa
domain: Domínio Customizado

6 changes: 6 additions & 0 deletions db/migrate/20181027190121_add_domain_to_companies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddDomainToCompanies < ActiveRecord::Migration[5.2]
def change
add_column :companies, :domain, :string
add_index :companies, :domain
end
end
3 changes: 3 additions & 0 deletions spec/features/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

fill_in placeholder: 'Company name', with: 'Galactic Empire'
fill_in placeholder: 'Company website', with: 'http://galacticempire.com'
fill_in placeholder: 'Custom domain', with: 'empire'

click_on 'Sign up'

expect(Company.last).to have_attributes(domain: 'empire', url: 'http://galacticempire.com', name: 'Galactic Empire')

expect(page).to have_text 'Submit your vacancy'
expect(page).to have_text 'Logout'

Expand Down

0 comments on commit 2a83e38

Please sign in to comment.