Skip to content

Commit

Permalink
Merge branch 'dev' into 555_show_agreement_letter_upload_form_only_wh…
Browse files Browse the repository at this point in the history
…en_accepted
  • Loading branch information
Fabian-Sommer committed Feb 8, 2017
2 parents f39feb2 + 4a91b91 commit c785f0a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/assets/stylesheets/profiles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/


.profile_details dt {
width: 200px;
white-space: normal;
}

.profile_details dd {
margin-left: 220px;
}
10 changes: 10 additions & 0 deletions app/assets/stylesheets/requests.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/


.request_details dt {
width: 200px;
white-space: normal;
}

.request_details dd {
margin-left: 220px;
}
2 changes: 1 addition & 1 deletion app/controllers/application_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def new
last_application_letter = ApplicationLetter.where(user: current_user).order("created_at").last
if last_application_letter
attrs_to_fill_in = last_application_letter.attributes
.slice("emergency_number", "vegetarian", "vegan", "allergies")
.slice("emergency_number", "organisation", "vegetarian", "vegan", "allergies")
@application_letter.attributes = attrs_to_fill_in
flash.now[:notice] = I18n.t('application_letters.fields_filled_in')
end
Expand Down
6 changes: 5 additions & 1 deletion app/views/application_letters/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
<% @application_letters.each do |application| %>
<tr>
<td><%= link_to application.event.name, event_path(application.event) %></td>
<td><%= application.status_type %></td>
<% if current_user.present? && current_user.role == 'pupil' && application.event.phase == :selection %>
<td><%= t('application_status.pending_after_deadline') %></td>
<% else %>
<td><%= application.status_type %></td>
<% end %>
<td>
<%= link_to t('.details'),
check_application_letter_path(application), :class => 'btn btn-default btn-xs' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1><%=t '.title', :default => model_class.model_name.human.titleize %></h1>
</div>

<dl class="dl-horizontal">
<dl class="dl-horizontal profile_details">
<% [:first_name, :last_name, :gender, :birth_date, :street_name, :zip_code, :city, :state, :country, :discovery_of_site].each do |attr_name| %>
<dt><strong><%= model_class.human_attribute_name(attr_name) %>:</strong></dt>
<% if attr_name == :gender %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/requests/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</div>

<h3><%=t 'requests.workshop_information' %></h3>
<dl class="dl-horizontal">
<dl class="dl-horizontal request_details">
<dt><strong><%= model_class.human_attribute_name(:topic_of_workshop) %>:</strong></dt>
<dd><%= @request.topic_of_workshop %></dd>
<dt><strong><%= model_class.human_attribute_name(:number_of_participants) %>:</strong></dt>
Expand All @@ -20,7 +20,7 @@
</dl>

<% if can? :set_contact_person, Request %>
<dl class="dl-horizontal">
<dl class="dl-horizontal request_details">
<dt><strong><%= model_class.human_attribute_name(:contact_person) %>:</strong></dt>
<dd>
<%= form_for @request, url: request_set_contact_person_path(@request), html: { class: 'form-inline' } do |f| %>
Expand All @@ -38,7 +38,7 @@
<% end %>
<% if can? :set_notes, Request %>
<dl class="dl-horizontal">
<dl class="dl-horizontal request_details">
<dt><strong><%= model_class.human_attribute_name(:notes) %>:</strong></dt>
<dd>
<%= form_for @request, url: request_set_notes_path(@request) do |f| %>
Expand All @@ -52,7 +52,7 @@
<% end %>

<h3><%= t('requests.personal_information') %></h3>
<dl class="dl-horizontal">
<dl class="dl-horizontal request_details">
<dt><strong><%= model_class.human_attribute_name(:first_name) %>:</strong></dt>
<dd><%= @request.first_name %></dd>
<dt><strong><%= model_class.human_attribute_name(:last_name) %>:</strong></dt>
Expand Down
11 changes: 11 additions & 0 deletions spec/factories/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@
end
end

trait :in_selection_phase_with_no_mails_sent_and_application do
after(:build) do |event, evaluator|
create_list(:application_letter, 1, event: event, status: :accepted)

event.published = true
event.application_deadline = Date.yesterday
event.acceptances_have_been_sent = false
event.rejections_have_been_sent = false
end
end

trait :in_selection_phase_with_participants_locked do
after(:build) do |event|
event.published = true
Expand Down
1 change: 1 addition & 0 deletions spec/features/application_letters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
end

check_filled_field.call(:emergency_number)
check_filled_field.call(:organisation)
check_filled_field.call(:allergies)
check_checked_checkbox.call(:vegetarian)
check_checked_checkbox.call(:vegan)
Expand Down
20 changes: 20 additions & 0 deletions spec/views/application_letters/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,24 @@
render
expect(rendered).to have_link(@application_letters[0].event.name, href: event_path(@application_letters[0].event.id))
end

it "should hide the temporary state of an applicant from the user" do
@event = assign(:event, FactoryGirl.create(:event, :in_selection_phase_with_no_mails_sent_and_application))
@application_letter = @event.application_letters[0]
@application_letter.user = FactoryGirl.create(:user_with_profile, role: :pupil)
@application_letters = @event.application_letters
@current_user = sign_in(@event.application_letters[0].user)
render
expect(rendered).to have_text(I18n.t('application_status.pending_after_deadline'))
end

it "should show the temporary state of an applicant to a coach" do
@event = assign(:event, FactoryGirl.create(:event, :in_selection_phase_with_no_mails_sent_and_application))
@application_letter = @event.application_letters[0]
@application_letter.user = FactoryGirl.create(:user_with_profile, role: :coach)
@application_letters = @event.application_letters
@current_user = sign_in(@application_letter.user)
render
expect(rendered).to have_text(@application_letter.status_type)
end
end

0 comments on commit c785f0a

Please sign in to comment.