- Allows a guest to book a tour
spec/features/guest_book_tour_spec.rb
Read through and manually check the feature test for this story
| var c = console.log.bind(console); // allows you to replace console.log(message) in your code with c(message) |
| module BookingFeatureHelpers | |
| def fill_in_booking_attributes inputs = {} | |
| attrs = booking_attributes.merge user_attributes | |
| attrs.merge! inputs | |
| attrs = attrs.with_indifferent_access | |
| [:name, :email, :phone_number, :number_of_people].each do |field| | |
| if attrs[field].present? | |
| find("[name*=#{field.to_s}]").set attrs[field] |
| module Starbucks | |
| def self.order(&block) | |
| order = Order.new | |
| order.instance_eval(&block) | |
| return order.drinks | |
| end | |
| class Order |
| require 'date' | |
| def generate_date do | |
| now = Date.today().to_datetime() | |
| weeks_from_now = Random.rand(8) | |
| day_random = RandomGaussian.new(0.5, 0.25).rand() | |
| day_of_week = (day_random*7+1.5).round() % 7 | |
| time_random = RandomGaussian.new(0.5, 0.1).rand() | |
| time = ((time_random*48+12).round() % 48)/2 |
| $(function() { | |
| var counter =0; | |
| function loadNext() { | |
| $('<div>').load('api/thumbnails/whatever/your/url/is?page=' + counter++).appendTo('#thumbnails'); | |
| } | |
| $(window).on('scroll', function() { | |
| if ($(document).scrollTop() > document.body.height() - (window.clientHeight / 25)) { | |
| loadNext(); | |
| }); |
| context "policy_scope" do | |
| let(:user) { create :user } | |
| let(:admin_user) { create :user, :admin } | |
| let!(:bookings) { create_list :booking, 2 } | |
| let!(:user_bookings) { create_list :booking, 2, user: user } | |
| it "should not include any models for non-admins" do | |
| BookingPolicy::Scope.new(user, Bookings).resolve.tap do |scope| | |
| expect(scope.all.count).to eq 0 | |
| end |
I hereby claim:
To claim this, I am signing this object:
Thanks so much for posting this. I have been in far too many of those places; even then the reality isn't as bad as described, in most cases, the person you're dealing with may not be responsible for your bad experience.
As Entrepreneurs and owners, and operators, we should also remember that we employ these people and that when we are in better shape we should find out our employees' stories and support them. If we're doing it right, they are our bread and butter, and we owe the sustainability of our model to them, the future of our business depends, to some degree, on their personal successes and failures, and if they can go on if life gives them a sucker punch.
| function pre(process, func){ | |
| return function(){ | |
| return func.apply(process(this), arguments); | |
| } | |
| } | |
| function jquerify (func){ return pre($, func); } | |
| $('div').map(jquerify(function(v, i){ | |
| return this.attr('id'); |