Skip to content

Commit

Permalink
Extract vacancy item section into a component partial (#94)
Browse files Browse the repository at this point in the history
In order to have a consistent vacancy item section in all views,
extract it into a component partial that can be used in all views.

This will fix the problem that the vacancy card from the `My Vacancies`
is different from the `All Vacancies` view.
  • Loading branch information
duduribeiro committed Mar 31, 2018
1 parent 52ac834 commit be49b86
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 43 deletions.
22 changes: 1 addition & 21 deletions app/views/company/vacancies/_vacancy.html.erb
@@ -1,21 +1 @@
<section class="vacancy-item ">
<div class="row">
<div class="col-md-1 col-xs-5">
<%= image_tag("ico-company-default.png", class: 'img-responsive img-company') %>
</div>
<div class="col-md-9 col-xs-6">
<div class="vacancy-title">
<span class="text-primary show-title-vacancy">
<%= vacancy.job_title %>
</span>
</div>
<div class="vacancy-details">
<span><i class="fa fa-briefcase" aria-hidden="true"></i><%= vacancy.company_name %></span>
<span><i class="fa fa-map-marker" aria-hidden="true"></i><%= vacancy.location %></span>
</div>
</div>
<div class="col-md-2 col-xs-12">
<%= link_to t("messages.edit_vacancy"), edit_vacancy_path(vacancy.id), class: "btn btn-primary btn-border-bottom-primary vertical-25 grow" %>
</div>
</div>
</section>
<%= render 'components/vacancy_item', vacancy: vacancy, link: edit_vacancy_path(vacancy.id) %>
29 changes: 29 additions & 0 deletions app/views/components/_vacancy_item.html.erb
@@ -0,0 +1,29 @@
<%#
Vacancy Item
Provide a card containing job's information, when clicked it gets redirected to the URL specified in the parameter.
@param vacancy [Vacancy] * the vacancy object.
@param link [String] * the string containing the URL that will be redirected when the section is clicked.
%>

<section class="vacancy-item ">
<%= link_to link do %>
<div class="row">
<div class="col-md-1 col-xs-5">
<%= image_tag("ico-company-default.png", class: 'img-responsive img-company') %>
</div>
<div class="col-md-9 col-xs-6">
<div class="vacancy-title">
<span class="text-primary show-title-vacancy">
<%= vacancy.job_title %>
</span>
</div>
<div class="vacancy-details">
<span><i class="fa fa-briefcase" aria-hidden="true"></i><%= vacancy.company_name %></span>
<span><i class="fa fa-map-marker" aria-hidden="true"></i><%= vacancy.location %></span>
</div>
</div>
</div>
<% end %>
</section>
21 changes: 1 addition & 20 deletions app/views/vacancies/_vacancy.html.erb
@@ -1,20 +1 @@
<section class="vacancy-item ">
<%= link_to vacancy_path(vacancy) do %>
<div class="row">
<div class="col-md-1 col-xs-5">
<%= image_tag("ico-company-default.png", class: 'img-responsive img-company') %>
</div>
<div class="col-md-9 col-xs-6">
<div class="vacancy-title">
<span class="text-primary show-title-vacancy">
<%= vacancy.job_title %>
</span>
</div>
<div class="vacancy-details">
<span><i class="fa fa-briefcase" aria-hidden="true"></i><%= vacancy.company_name %></span>
<span><i class="fa fa-map-marker" aria-hidden="true"></i><%= vacancy.location %></span>
</div>
</div>
</div>
<% end %>
</section>
<%= render 'components/vacancy_item', vacancy: vacancy, link: vacancy_path(vacancy) %>
1 change: 0 additions & 1 deletion app/views/vacancies/index.html.erb
@@ -1,4 +1,3 @@

<section class="bg-vacancy-intro">
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 1 addition & 1 deletion spec/features/edit_vacancy_spec.rb
Expand Up @@ -10,7 +10,7 @@
zoo_keeper = create(:vacancy, job_title: 'ZooKeeper', company_id: user.company.id)
visit company_vacancies_path(as: user)

click_link 'Edit', href: edit_vacancy_path(zoo_keeper.id)
click_link zoo_keeper.job_title

expect(current_path).to eql(edit_vacancy_path(zoo_keeper.id))
expect(page).to have_content(I18n.t('vacancies.edit.edit_vacancies'), wait: 10)
Expand Down

0 comments on commit be49b86

Please sign in to comment.