Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FixRentAbilities #146

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(user)
# TODO Should be removed when everyone is required to log in.
# /d.wessman 2015-03-28
can [:read, :update_worker, :remove_worker, :authorize], CafeWork
can [:read, :main], Rent
can [:read, :main, :new, :edit, :update, :create, :authorize], Rent

# Abilities all signed in users get
if user.id
Expand Down
10 changes: 5 additions & 5 deletions app/views/rents/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<%= f.label 'E-post & telefon', class: 'reg-label' %>
<div class="margin-bottom-20">
<div class="row">
<div class="col-md-6"><%= f.text_field :email, class: 'form-control', placeholder: "Epost" %></div>
<div class="col-md-6"> <%= f.text_field :phone, class: 'form-control', placeholder: "Telefon" %></div>
<div class="col-md-6"><%= f.email_field :email, class: 'form-control', placeholder: "Epost" %></div>
<div class="col-md-6"> <%= f.phone_field :phone, class: 'form-control', placeholder: "Telefon" %></div>
</div>
</div>
<% if current_user %>
Expand All @@ -43,11 +43,11 @@
</div>
<%= f.label 'Från', class: 'reg-label' %>
<div class="margin-bottom-20">
<%= f.datetime_select :d_from, minute_step: 10, class: 'form-control' %>
<%= f.text_field :d_from, class: 'datetimepicker' %>
</div>
<%= f.label 'Till', class: 'reg-label' %>
<div class="margin-bottom-20">
<%= f.datetime_select :d_til, minute_step: 10, class: 'form-control' %>
<%= f.text_field :d_til, class: 'datetimepicker' %>
</div>
<% if (@rents)&&(@rents.count > 0) %>
Bokningar (från idag + 30 dagar):<br>
Expand Down Expand Up @@ -81,4 +81,4 @@
</div>
</div>
</div>
<% end %>
<% end %>
18 changes: 18 additions & 0 deletions spec/features/rent_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'rails_helper'
feature 'tries to rent the car', js: true do
let(:rent) { build(:rent) }
scenario 'they get alert with text "Loggade in"' do
visit '/bil/bokningar/ny'
find(:css, '#rent_disclaimer').set(true)
fill_in 'rent_name', with: rent.name
fill_in 'rent_lastname', with: rent.lastname
fill_in 'rent_email', with: rent.email
fill_in 'rent_phone', with: rent.phone
fill_in 'rent_purpose', with: rent.purpose
# This does not work, we need to figure out how to set a date in the
# datepicker. Remember we can execute scripts by page.execute_script
fill_in 'rent_d_from', with: rent.d_from
fill_in 'rent_d_til', with: rent.d_til
click_button 'Spara'
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
require 'capybara/rspec'
require 'capybara/rails'

require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist

# I had to include this, /d.wessman 2015-03-20
require 'database_cleaner'
# Devise helpers
Expand Down