From c1d1361ac6d9ba0900360391cba5bf2c3b22fcb1 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Thu, 19 Jun 2014 19:10:10 -0400 Subject: [PATCH 01/26] first attempts --- Gemfile | 1 + Gemfile.lock | 2 + .../equipment_models_controller.rb | 6 + app/views/equipment_models/_calendar.html.erb | 8 + app/views/equipment_models/calendar.html.erb | 20 + app/views/equipment_models/show.html.erb | 4 + spec/mailers/admin_mailer_spec.rb | 27 + spec/mailers/user_mailer_spec.rb | 6 + test.txt | 1366 +++++++++++++++++ 9 files changed, 1440 insertions(+) create mode 100644 app/views/equipment_models/_calendar.html.erb create mode 100644 app/views/equipment_models/calendar.html.erb create mode 100644 spec/mailers/admin_mailer_spec.rb create mode 100644 spec/mailers/user_mailer_spec.rb create mode 100644 test.txt diff --git a/Gemfile b/Gemfile index a23769dc8..f276263aa 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,7 @@ gem 'rails3-jquery-autocomplete' gem 'select2-rails' gem 'kaminari' gem 'spinjs-rails' +gem "watu_table_builder", :require => "table_builder" #forms / formatting gem 'dynamic_form' diff --git a/Gemfile.lock b/Gemfile.lock index f7d23f796..481f75c1f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -298,6 +298,7 @@ GEM uglifier (2.2.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + watu_table_builder (0.3.0) websocket (1.0.7) whenever (0.8.4) activesupport (>= 2.3.4) @@ -361,5 +362,6 @@ DEPENDENCIES therubyracer thin uglifier + watu_table_builder whenever yajl-ruby diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index e5036f667..2109f0bcc 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -26,8 +26,14 @@ def index def show @associated_equipment_models = @equipment_model.associated_equipment_models.sample(6) + @model_reservations = Reservation.active.for_eq_model @equipment_model + @date = Date.today + @beginning = Date.today.beginning_of_week(:sunday) + binding.pry + render 'calendar' end + def new @equipment_model = EquipmentModel.new(category: @category) end diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb new file mode 100644 index 000000000..d097a7f37 --- /dev/null +++ b/app/views/equipment_models/_calendar.html.erb @@ -0,0 +1,8 @@ +
+ +<% for d in @beginning..@beginning+7.day %> +
+ <%= d.day %> +
+<% end %> +
diff --git a/app/views/equipment_models/calendar.html.erb b/app/views/equipment_models/calendar.html.erb new file mode 100644 index 000000000..ed9030d2d --- /dev/null +++ b/app/views/equipment_models/calendar.html.erb @@ -0,0 +1,20 @@ +
+ +<% for d in @beginning...(@beginning+7.day) %> +
+ <%= d.day %> + <% @model_reservations.each do |r| %> + <% if r.start_date.to_date == d %> +
+ <% if r.equipment_object %> + <% label = r.equipment_object.name %> + <% else %> + <% label = 'Reserved' %> + <% end %> + <%= label %> +
+ <% end %> + <% end %> +
+<% end %> +
diff --git a/app/views/equipment_models/show.html.erb b/app/views/equipment_models/show.html.erb index 8cb2df8bd..c506955ca 100644 --- a/app/views/equipment_models/show.html.erb +++ b/app/views/equipment_models/show.html.erb @@ -2,6 +2,8 @@ <% subtitle Category.find(@equipment_model.category_id).name %> + <%= render :partial => 'calendar' %> +
@@ -25,6 +27,8 @@ <%= image_tag "no-image-260.gif" %> <% end %>
+ +
diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb new file mode 100644 index 000000000..7db8af09a --- /dev/null +++ b/spec/mailers/admin_mailer_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe AdminMailer do + + shared_examples_for "admin email" do + it "is only sent to one address" do + expect(mail.to.size).to eq(1) + end + it "is to the admin" do + expect(mail.to.first).to eq(AppConfig.first.admin_email) + end + it "delivers" do + expect { mail.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + describe 'Notes Reservation Notification' do + subject(:res){FactoryGirl.build(:valid_reservation, :notes => "notes")} + subject(:mail) {AdminMailer.notes_reservation_notification(res,res)} + it_behaves_like "admin email" + end + describe 'overdue checked in email' do + # subject(:res){FactoryGirl.build(:valid_reservation)} + # subject(:mail) {AdminMailer.overdue_checked_in_fine_admin(res)} + # it_behaves_like 'admin email' + end +end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb new file mode 100644 index 000000000..bc08b0340 --- /dev/null +++ b/spec/mailers/user_mailer_spec.rb @@ -0,0 +1,6 @@ +require 'spec_helper' + +describe UserMailer do + + +end diff --git a/test.txt b/test.txt new file mode 100644 index 000000000..6aba0cca9 --- /dev/null +++ b/test.txt @@ -0,0 +1,1366 @@ +Run options: include {:focus=>true} + +All examples were filtered out; ignoring {:focus=>true} + +CheckinProcedure + should belong to equipment_model + +Cart + has a working factory + General validations + should require reserver_id to be set + should require start_date to be set + should require due_date to be set + Reservation date changes + .set_due_date + sets new due dates for all items in cart + .set_start_date + does not set a past date as start date + sets new start and due dates for all items in cart + .fix_due_date + sets due date as start_date + 1 if due date precedes start date + does not affect due date when due date does not precede start date + Aliases + .cart_reservations + finds items + .models_with_quantities + gets the correct count of models + .reserver + should return a correct user instance + .duration + should calculate the sum correctly + .set_reserver_id + should flag every CartReservation with passed user_id + .persisted? + should be false + .initialize + has no items + has no reserver + is due tomorrow + starts today + has errors + .empty? + is true when there are no items in cart + is false when there are some items in cart + Item handling + .add_item + adds an item + .remove_item + removes an item from cart + removes a CartReservation from database + removes the right model from cart + +EquipmentObjectsController + GET index + with admin user + should respond with 200 + should render template matcher "index" + should not set the flash + without show deleted + with @equipment_model set + should populate an array of all active model-type equipment objects + without @equipment_model set + should populate an array of all active equipment objects (FAILED - 1) + with show deleted + with @equipment_model set + should populate an array of all model-type equipment objects + without @equipment_model set + should populate an array of all equipment objects (FAILED - 2) + with checkout person user + should respond with 200 + should render template matcher "index" + with non-admin user + should redirect to root + DELETE destroy + with admin user + should remove object from database + + should set the flash + should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 84, created_at: "2014-06-19 20:51:32", updated_at: "2014-06-19 20:51:32", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> + sets @equipment_object to selected object + with non-admin user + should redirect to root + GET edit + with admin user + should respond with 200 + should render template matcher "edit" + sets @equipment_object to selected object + should not set the flash + with non-admin user + should redirect to root + GET new + with admin user + should respond with 200 + sets equipment_model when one is passed through params + assigns a new equipment object to @equipment_object + should not set the flash + should render template matcher "new" + sets equipment_model to nil when no equipment model is specified + with non-admin user + should redirect to root + GET show + with admin user + should respond with 200 + should render template matcher "show" + should set to correct equipment object + should not set the flash + with non-admin user + should redirect to root + PUT update + with admin user + with valid attributes + should set the flash + sets @equipment_object to selected object + should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 106, created_at: "2014-06-19 20:51:35", updated_at: "2014-06-19 20:51:35", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> + updates attributes + without valid attributes + should not set the flash + should not update attributes + should render template matcher "edit" + with non-admin user + should redirect to root + POST create + with admin user + with valid attributes + should save object + should set the flash + should change default serial to nil + should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 115, created_at: "2014-06-19 20:51:36", updated_at: "2014-06-19 20:51:36", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> + without valid attributes + should not set the flash + should render template matcher "new" + should render template matcher "new" + should not save + with non-admin user + should redirect to root + +Reservation + should belong to equipment_model + should require equipment_model to be set + should belong to checkout_handler + should belong to equipment_object + should belong to reserver + should belong to checkin_handler + when valid + should be valid + should respond to #late_fee + passes custom validations + should respond to #max_renewal_length_available + should save (FAILED - 3) + should have a valid reserver + should respond to #fake_reserver_id + can be updated + equipment_model + should not be nil + start_date + should not be nil + due_date + should not be nil + with no user + should have a deleted user + should be valid + when overdue + should be is eligible for renew + status + should == "overdue" + when not checked out + status + should == "reserved" + when missed + status + should == "missed" + when checked in + should not be is eligible for renew + status + should == "returned on time" + with equipment model quantity problems + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 4) + passes other custom validations + when user has overdue reservation + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 5) + passes other custom validations + with equipment object/model matching problems + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 6) + passes other custom validations + when empty + should not be valid + should not save (FAILED - 7) + updates with equipment model (FAILED - 8) + cannot be updated + with category quantity problems + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 9) + passes other custom validations + with past due date + should not be valid + updates with fixed date (FAILED - 10) + fails appropriate validations + cannot be updated + should not save (FAILED - 11) + passes other custom validations + when checked out + should be is eligible for renew + status + should == "checked out" + with duration problems + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 12) + passes other custom validations + with equipment object available problems + passes other custom validations + with blacked out start date + should not be valid + fails appropriate validations + cannot be updated + should not save (FAILED - 13) + passes other custom validations + +Category + validates max_per_user must be non-negative + validates max_renewal_times can be nil + validates sort_order can be nil + validates max_checkout_length must be an integer + validates sort_order must be an integer + validates max_checkout_length can be nil + validates renewal_days_before_due must be an integer + validates max_renewal_times must be an integer + validates sort_order must be non-negative + validates renewal_days_before_due can be nil + validates max_renewal_length must be an integer + validates max_renewal_times must be non-negative + validates max_per_user can be nil + should have many equipment_models + validates max_per_user must be an integer + validates renewal_days_before_due must be non-negative + validates max_checkout_length must be non-negative + should require name to be set + validates max_renewal_length must be non-negative + should require case sensitive unique value for name + validates max_renewal_length can be nil + .active + Should return all active categories + Should not return inactive categories + .catalog_search + Should return names matching all of the query words + Should not return any categories without every query word in the name + #maximum_renewal_days_before_due + Should return maximum_renewal_days_before_due if defined + Default to unrestricted if not defined + #maximum_renewal_length + Should return maximum_renewal_length if defined + Default to 0 if not defined + #maximum_per_user + Should return maximum_per_user if defined + Should return 'unrestricted' if not defined + #maximum_checkout_length + Should return maximum_checkout_length if defined + Default to unrestricted if not defined + #maximum_renewal_times + Should return maximum_renewal_times if defined + Default to unrestricted if not defined + +Requirement + Validations + has a working factory (FAILED - 14) + should have and belong to many users + should require contact_info to be set + should require description to be set + should require contact_name to be set + should have and belong to many equipment_models + #list_requirement_admins + should return a list of admins and contact info if no requirements have been met. (FAILED - 15) + should return a list of met requirements, followed by unmet requirements if they exists (FAILED - 16) + +AppConfig + has a working factory + has an attachment that is of the favicon format + shouldn't have an invalid e-mail + does not accept too long a site title + does not accept empty site title + should have a valid and present e-mail + +RequirementsController + GET index + is admin + example at ./spec/controllers/requirements_controller_spec.rb:19 (FAILED - 17) + example at ./spec/controllers/requirements_controller_spec.rb:20 (FAILED - 18) + should populate an array of all requirements (FAILED - 19) + should not set the flash + not an admin + should redirect to root url if not an admin + DELETE destroy + is admin + assigns the selected requirement to @requirement + removes @requirement from the database + should redirect to the requirements index page + not admin + should redirect to root url if not an admin + PUT update + is admin + with valid attributes + should set @requirement to the correct requirement + should update the attributes of @requirement + should set the flash + should redirect to # + with invalid attributes + should not update the attributes of @requirement + should render template matcher "edit" + should not set the flash + not admin + should redirect to root url if not an admin + GET new + is admin + should respond with 200 + should render template matcher "new" + assigns a new requirement to @requirement + should not set the flash + not an admin + should redirect to root url if not an admin + GET show + is an admin + should respond with 200 + should render template matcher "show" + should set @requirement to the selected requirement + should not set the flash + not an admin + should redirect to root url if not an admin + POST create + is admin + with valid attributes + saves a new requirement + should redirect to # + should set the flash + with invalid attributes + fails to save a new requirment + should not set the flash + should render template matcher "new" + not admin + should redirect to root url if not an admin + GET edit + is admin + should set @requirement to the selected requirement + should respond with 200 + should not set the flash + should render template matcher "edit" + not admin + should redirect to root url if not an admin + +Blackout + validations and associations + should require notice to be set + validates a set_id if it is a recurring blackout (PENDING: Not yet implemented) + should require equipment_model_id to be set + should require end_date to be set + should require start_date to be set + should belong to equipment_model + should require blackout_type to be set + .blackouts_on_date + Should return the blackout blocking a passed date if exists + Should return nil if the date is not blacked out + Should return an array if multiple blackouts cover date + .hard_blackout_exists_on_date + Should return true if there is a hard blackout on the given date + Should return false if there is a soft blackout or no blackout on the given date + +AdminMailer + Notes Reservation Notification + behaves like admin email + is only sent to one address + is to the admin + delivers + +ContactController + GET new + should assign @message to a new message + should respond with 200 + should not set the flash + should render template matcher "new" + POST create + with valid attributes + sends a message (FAILED - 20) + should redirect to "/" + should set the flash + with invalid attributes + should render template matcher "new" + should set the flash + should not send a message + +EquipmentModelsController + GET index + with admin user + should respond with 200 + should render template matcher "index" + should not set the flash + without show deleted + with @category set + should populate an array of of active category-type equipment models + without @category set + should populate an array of all active equipment models (FAILED - 21) + with show deleted + with @category set + should populate an array of category-type equipment models + without @category set + should populate an array of all equipment models (FAILED - 22) + with non-admin user + should function normally + should respond with 200 + should render template matcher "index" + DELETE destroy + with admin user + should remove model from database + + sets @equipment_object to selected model + should set the flash + should redirect to "http://test.host/equipment_models" + with non-admin user + DELETE destroy should redirect to root + POST create + with admin user + with valid attributes + should save model + should set the flash + should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 279, created_at: "2014-06-19 20:51:57", updated_at: "2014-06-19 20:51:57", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> + without valid attributes + should set the flash + should render template matcher "new" + should render template matcher "new" + should not save + with non-admin user + should redirect to root + GET new + with admin user + should respond with 200 + sets category when one is passed through params + assigns a new equipment model to @equipment_model + should not set the flash + should render template matcher "new" + sets equipment_model to nil when no category is specified + with non-admin user + should redirect to root + GET show + with admin user + should respond with 200 + should limit @associated_equipment_models to maximum 6 + should set to correct equipment model + should not set the flash + should render template matcher "show" + should set @associated_equipment_models + with non-admin user + should funciton normally + should respond with 200 + should render template matcher "show" + PUT update + with admin user + calls delete_files (PENDING: Not yet implemented) + with valid attributes + example at ./spec/controllers/equipment_models_controller_spec.rb:215 (FAILED - 23) + sets @equipment_model to selected model (FAILED - 24) + example at ./spec/controllers/equipment_models_controller_spec.rb:223 (FAILED - 25) + updates attributes (FAILED - 26) + without valid attributes + should not set the flash + should not update attributes + should render template matcher "edit" + with non-admin user + should redirect to root + GET edit + with admin user + should respond with 200 + should render template matcher "edit" + sets @equipment_model to selected model + should not set the flash + with non-admin user + should redirect to root + +CheckoutProcedure + should belong to equipment_model + +TestController + app_setup_check + user and appconfig in the db + should respond with 200 + should render template matcher {:text=>"hello world"} + should not set the flash + no app_config + should set the flash + should render template matcher ["layouts/application", "application_setup/index"] + no user in the db + should set the flash + should render template matcher ["layouts/application", "application_setup/index"] + fix_cart_date + changes cart.start_date to today if date is in the past + does not change the start_date if date is in the future + cart + makes a new cart record for session[:cart] if !cart + returns session[:cart] if cart.reserver_id + returns session[:cart] without a reserver_id if !cart.reserver_id && !current_user + sets the session[:cart].reserver_id to current_user.id if !cart.reserver_id && current_user + seen_app_configs + app configs have not been viewed + should set the flash + should respond with 300..399 + should redirect to "/app_configs" + app configs have been viewed + should not set the flash + should respond with 200 + should not redirect to "/app_configs" + first_time_user + current_user exists + should not set the flash + should not redirect + current_user is nil + should set the flash + should redirect to "/users/new" + params[:action] = "terms_of_service" + should not set the flash + should not redirect + require_admin + admin user + does nothing if admin in admin mode (PENDING: Not yet implemented) + not an admin + redirects to root url if not an admin and no parameter passed (PENDING: Not yet implemented) + redirects to new_path if not an admin and new_path passed (PENDING: Not yet implemented) + redirects to new path admin not in admin mode (PENDING: Not yet implemented) + current_user + @current_user already exists + should return the current user + @current_user does not already exist + session[:cas_user] exists + should find the current user based on the session :cas_user + session[:cas_user] does not exist + should return nil + check_if_is_admin + user is an admin + should not set the flash + should not redirect + user is not an admin + should set the flash + should redirect to "where_i_came_from" + load_configs + should set @app_configs to the first AppConfig + +EquipmentObject + validations + has a working factory + should require name to be set + saves an empty string value as nil for deleted_at field + should require equipment_model to be set + .current_reservation + returns nil if the equipment object does not have an associted reservation + returns the reservation object currently holding this equipment_object if there is one that does + .status + returns 'Deactivated' if the object has a value for deleted_at + returns 'available' if the object is active and not currently checked out + returns a description of the reservation that it is currently associated with if it is active and checked out + .active + Should return all active equipment objects + Should not return inactive equipment objects + .available? + returns true if the equipment object is not checked out + returns false if the equipment object is currently checked out + +Message + validations + should require name to be set + should allow email to be set to any of ["example@example.com", "1a@a.edu", "a@2a.net"] + should require body to be set + should require subject to be set + should require email to be set + should not allow email to be set to any of ["abc", "!s@abc.com", "a@!d.com", "a@a.c0m"] + .persisted? + should always return false + +AnnouncementsHelper + add some examples to (or delete) /home/s/Dropbox/code/STC/reservations/spec/helpers/announcements_helper_spec.rb (PENDING: No reason given) + +Announcements + displays active announcements (FAILED - 27) + +CatalogController + GET index + sets @reserver_id to the current cart.reserver_id + should respond with 200 + should not set the flash + should render template matcher "index" + PUT update_user_per_cat_page + should set session[:user_per_cat_page] to session[:user_cat_items_per_page] if exists + should not alter session[:user_per_cat_page] if session[:user_cat_items_per_page] is nil + should render template matcher {:action=>"cat_pagination"} + should redirect to "/" + PUT remove_from_cart + valid equipment_model selected + should call cart.remove_item to remove item from cart + should set flash[:error] to the result of Reservation.validate_set if exists + should render template matcher {:action=>"update_cart"} + should redirect to "/" + invalid equipment_model selected + should redirect to "/" + should set the flash + should add logger error (FAILED - 28) + PUT add_to_cart + valid equipment_model selected + should call cart.add_item to add item to cart + should set flash[:error] to the result of Reservation.validate_set if exists + should render template matcher {:action=>"update_cart"} + should redirect to "/" + invalid equipment_model selected + should redirect to "/" + should set the flash + should add logger error (FAILED - 29) + PUT search + query is blank + should redirect to "/" + query is not blank + should call catalog_search on EquipmentModel and return active equipment models + should call catalog_search on EquipmentObject + should render template matcher {:action=>"search_results"} + should call catalog_search on Category + +CategoriesController + GET index + user is admin + should populate an array of all categories if show deleted is true (FAILED - 30) + should render template matcher "index" + should respond with 200 + should populate an array of active categories if show deleted is nil or false (FAILED - 31) + should not set the flash + user is not admin + should respond with 200 + should populate an array of all categories if show deleted is true (FAILED - 32) + should not set the flash + should render template matcher "index" + should populate an array of active categories if show deleted is nil or false (FAILED - 33) + DELETE destroy + is admin + assigns the selected category to @category + removes @category from the database + should redirect to the categorys index page + not admin + should redirect to root url + GET edit + is admin + should set @category to the selected category + should respond with 200 + should not set the flash + should render template matcher "edit" + not admin + should redirect to root_url + GET new + is admin + should respond with 200 + should render template matcher "new" + assigns a new category to @category + should not set the flash + not admin + should redirect to root_url + GET show + user is admin + should respond with 200 + should render template matcher "show" + should set @category to the selected category + should not set the flash + user is not admin + should respond with 200 + should render template matcher "show" + should set @category to the selected category + should not set the flash + PUT update + is admin + with valid attributes + should set @category to the correct category + should successfully save new attributes to the database + should set the flash + should redirect to # + with invalid attributes + should not update attributes of @category in the database + should render template matcher "edit" + should not set the flash + not admin + should redirect to root url + POST create + is admin + with valid attributes + saves a new category to the database + should redirect to # + should set the flash + with invalid attributes + fails to save a new category + should set the flash + should render template matcher "new" + not admin + should redirect to root url + +AppConfigsController + GET edit + app_config exists already + user is admin + should render template matcher "edit" + should respond with 200 + should assign @app_config variable to the first appconfig in the db + should not set the flash + user is not admin + should redirect to "/" + app_config does not exist yet + should respond with 200 (FAILED - 34) + should set the flash + should render template matcher ["layouts/application", "application_setup/index"] + POST update + app config already exists + user is admin + assigns current configuration to @app_config (FAILED - 35) + With valid parameters + resets TOS status for all users when :reset_tos_for_users is 1 + maintains TOS status for all users when :reset_tos_for_users is not 1 + restores favicon when appropriate (PENDING: Not yet implemented) + user is not admin + should redirect to "/" + app_config does not exist yet + should respond with 200 (FAILED - 36) + should set the flash + should render template matcher ["layouts/application", "application_setup/index"] + +ApplicationController + PUT update_cart + valid parameters + should update cart dates + should not set the flash + invalid parameters + should set the flash + GET markdown_help + should render template matcher "shared/_markdown_help" + PUT deactivate + should assign @objects_class2 to the object and controller specified by params (PENDING: Not yet implemented) + should delete @objects_class2 (PENDING: Not yet implemented) + should redirect to request.referer (PENDING: Not yet implemented) + should set the flash (PENDING: Not yet implemented) + GET logout + should always set @current_user to nil + should log the user out of CAS (PENDING: Not yet implemented) + DELETE empty_cart + destroys cart reservations for the reserver associated with the current cart + sets the session[:cart] variable back to nil + should set the flash + should redirect to "/" + PUT activate + should assign @model_to_activate to the model to be activated (PENDING: Not yet implemented) + should set the flash (PENDING: Not yet implemented) + should revive @model_to_activate (PENDING: Not yet implemented) + should call activatParents on the assigned model (PENDING: Not yet implemented) + should redirect to request.referer (PENDING: Not yet implemented) + GET terms_of_service + should render template matcher "terms_of_service/index" + assigns @app_config.terms_of_service to @tos + +Announcement + has current scope (FAILED - 37) + does not include ids passed in to current (FAILED - 38) + includes current when nil is passed in (FAILED - 39) + +CartReservation + should belong to equipment_model + should belong to reserver + should require reserver to be set + when valid + should be valid + can be updated + should save + should have a valid reserver + passes custom validations + equipment_model + should not be nil + start_date + should not be nil + due_date + should not be nil + when empty + should not be valid + should not save + can be updated with equipment model + cannot be updated + with bad dates + should not be valid + should not save + can be updated with fixed date + cannot be updated + +User + has a working factory + validations and associations + should have many reservations + should not allow email to be set to any of ["abc", "!s@abc.com", "a@!d.com", "a@a.c0m"] + should require first_name to be set + should have and belong to many requirements + should require last_name to be set + should require case sensitive unique value for login + doesn't have to accept ToS if created by an admin + should allow email to be set to any of ["example@example.com", "1a@a.edu", "a@2a.net"] + should not allow nickname to be set to any of ["ab@", "ab1", "ab_c"] + should require affiliation to be set + must accept ToS + should require email to be set + should allow nickname to be set to any of [nil, "", "abc", "Example"] + should require login to be set + .name + should return the nickname and last name joined into one string if nickname is specified + should return the first and last name if user has no nickname specified + .checked_out_models + should return a hash of checked out models and counts + .can_checkout? + should return true if user is a checkout person + should return false if admin in normal mode + should return false if user is normal + should return true if user is an admin in checkoutperson mode + should return true if user is an admin in admin mode + should return false if admin in bannedmode + should return false if user is banned + nickname + should default to empty string + should not allow nil + .active + should return all active users + should not return inactive users + #search_ldap + should return a hash of user attributes if the ldap database has the login associated with user (PENDING: Not yet implemented) + should return nil if the user is not in the ldap database (PENDING: Not yet implemented) + #select_options + should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] (FAILED - 40) + .is_admin? + should return true if user is admin and passed no parameter + not an admin + should return false if user is not an admin and passed no parameter + should return false if user is not admin and passed a parameter + banned view_mode + should return true if passed the parameter matching the view_mode + should return false if passed a parameter not matching the view_mode + checkout view_mode + should return true if passed the parameter matching the view_mode + should return false if passed a parameter not matching the view_mode + admin view_mode + should return true if passed the parameter matching the view_mode + should return false if passed a parameter not matching the view_mode + normal view_mode + should return true if passed the parameter matching the view_mode + should return false if passed a parameter not matching the view_mode + .render_name + should return the nickname, last name, and login id as a string if nickname exists + should return the first name, last name, and login id as a string if no nickname + .equipment_objects + has a working reservation factory + should return all equipment_objects reserved by the user + +EquipmentModel + basic validations + requires an integer value for maximum renewal length + requires a maximum per user value greater than or equal to 1 + should accepts_nested_attributes_for :checkout_procedures + requires an integer value for renewal days before due + allows nil values for maximum per user + allows nil values for maximum renewal times + requires a late fee greater than or equal to 0 + should have and belong to many associated_equipment_models + requires a replacement fee greater than or equal to 0 + should require description to be set + should accepts_nested_attributes_for :checkin_procedures + should have many checkout_procedures + requires a maximum renewal length value greater than or equal to 0 + should have and belong to many requirements + requires an integer value for maximum renewal times + requires a maximum renewal times value greater than or equal to 0 + should require name to be set + has a working factory + allows nil values for renewal days before due + should have many reservations + should have many checkin_procedures + should belong to category + should have many equipment_objects + should require case sensitive unique value for name + requires an integer value for maximum per user + requires a renewal days before due value greater than or equal to 0 + allows nil values for maximum renewal length + requires an associated category + instance methods + .maximum_per_user + should return the max_per_user if specified + should return the associated category's max_per_user if unspecified + methods involving reservations + .num_available + should return the number of objects of that model available over a given date range + should return 0 if no objects of that model are available + .available_count + should take the total # of the model, subtract the number reserved, checked-out, and overdue for the given date and return the result + .number_overdue + should return the number of objects of a given model that are checked out and overdue + .number_reserved_on_date + should return the number of objects of that model reserved on that date but not checked in + .available_object_select_options + should make a string listing the available objects + .maximum_renewal_times + should return the max_renewal_times if specified + should return the associated category's max_renewal_length if unspecified + .maximum_renewal_length + should return the max_renewal_length if specified + should return the associated category's max_renewal_length if unspecified + .model_restricted? + should return false if the user has fulfilled the requirements to use the model + should return false if the model has no requirements + should return true if the user has not fulfilled any of the requirements + should return true if the user has not fulfilled all of the requirements + .maximum_renewal_days_before_due + should return the model's renewal_days_before_due if specified + should return the associated category's renewal_days_before_due if unspecified + class methods + #catalog_search + Should return equipment_models with all of the query words in either name or description + Should not return any equipment_models without every query word in the name or description (FAILED - 41) + association validations + has a working association callback + does not permit association with itself + .not_associated_with_self + creates an error if associated with self + +Pending: + Blackout validations and associations validates a set_id if it is a recurring blackout + # Not yet implemented + # ./spec/models/blackout_spec.rb:13 + EquipmentModelsController PUT update with admin user calls delete_files + # Not yet implemented + # ./spec/controllers/equipment_models_controller_spec.rb:236 + TestController require_admin admin user does nothing if admin in admin mode + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:266 + TestController require_admin not an admin redirects to root url if not an admin and no parameter passed + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:269 + TestController require_admin not an admin redirects to new_path if not an admin and new_path passed + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:270 + TestController require_admin not an admin redirects to new path admin not in admin mode + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:271 + AnnouncementsHelper add some examples to (or delete) /home/s/Dropbox/code/STC/reservations/spec/helpers/announcements_helper_spec.rb + # No reason given + # ./spec/helpers/announcements_helper_spec.rb:14 + AppConfigsController POST update app config already exists user is admin With valid parameters restores favicon when appropriate + # Not yet implemented + # ./spec/controllers/app_configs_controller_spec.rb:87 + ApplicationController PUT deactivate should assign @objects_class2 to the object and controller specified by params + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:378 + ApplicationController PUT deactivate should delete @objects_class2 + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:379 + ApplicationController PUT deactivate should redirect to request.referer + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:381 + ApplicationController PUT deactivate should set the flash + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:380 + ApplicationController GET logout should log the user out of CAS + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:362 + ApplicationController PUT activate should assign @model_to_activate to the model to be activated + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:385 + ApplicationController PUT activate should set the flash + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:388 + ApplicationController PUT activate should revive @model_to_activate + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:387 + ApplicationController PUT activate should call activatParents on the assigned model + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:386 + ApplicationController PUT activate should redirect to request.referer + # Not yet implemented + # ./spec/controllers/application_controller_spec.rb:389 + User#search_ldap should return a hash of user attributes if the ldap database has the login associated with user + # Not yet implemented + # ./spec/models/user_spec.rb:223 + User#search_ldap should return nil if the user is not in the ldap database + # Not yet implemented + # ./spec/models/user_spec.rb:224 + +Failures: + + 1) EquipmentObjectsController GET index with admin user without show deleted without @equipment_model set should populate an array of all active equipment objects + Failure/Error: expect(assigns(:equipment_objects).size).to eq(2) + + expected: 2 + got: 13 + + (compared using ==) + # ./spec/controllers/equipment_objects_controller_spec.rb:38:in `block (6 levels) in ' + + 2) EquipmentObjectsController GET index with admin user with show deleted without @equipment_model set should populate an array of all equipment objects + Failure/Error: expect(assigns(:equipment_objects).size).to eq(3) + + expected: 3 + got: 14 + + (compared using ==) + # ./spec/controllers/equipment_objects_controller_spec.rb:64:in `block (6 levels) in ' + + 3) Reservation when valid should save + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:30:in `block (3 levels) in ' + + 4) Reservation with equipment model quantity problems should not save + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:381:in `block (3 levels) in ' + + 5) Reservation when user has overdue reservation should not save + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:213:in `block (3 levels) in ' + + 6) Reservation with equipment object/model matching problems should not save + Failure/Error: Reservation.all.size.should == 0 + expected: 0 + got: 1 (using ==) + # ./spec/models/reservation_spec.rb:278:in `block (3 levels) in ' + + 7) Reservation when empty should not save + Failure/Error: Reservation.all.size.should == 0 + expected: 0 + got: 1 (using ==) + # ./spec/models/reservation_spec.rb:95:in `block (3 levels) in ' + + 8) Reservation when empty updates with equipment model + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:121:in `block (3 levels) in ' + + 9) Reservation with category quantity problems should not save + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:345:in `block (3 levels) in ' + + 10) Reservation with past due date updates with fixed date + Failure/Error: Reservation.all.size.should == 1 + expected: 1 + got: 2 (using ==) + # ./spec/models/reservation_spec.rb:157:in `block (3 levels) in ' + + 11) Reservation with past due date should not save + Failure/Error: Reservation.all.size.should == 0 + expected: 0 + got: 1 (using ==) + # ./spec/models/reservation_spec.rb:131:in `block (3 levels) in ' + + 12) Reservation with duration problems should not save + Failure/Error: Reservation.all.size.should == 0 + expected: 0 + got: 1 (using ==) + # ./spec/models/reservation_spec.rb:311:in `block (3 levels) in ' + + 13) Reservation with blacked out start date should not save + Failure/Error: Reservation.all.size.should == 0 + expected: 0 + got: 1 (using ==) + # ./spec/models/reservation_spec.rb:167:in `block (3 levels) in ' + + 14) Requirement Validations has a working factory + Failure/Error: @requirement.save.should be_true + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '1' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 1, NULL, '2014-06-19 20:51:48') + # ./spec/models/requirement_spec.rb:9:in `block (3 levels) in ' + + 15) Requirement#list_requirement_admins should return a list of admins and contact info if no requirements have been met. + Failure/Error: @requirement = FactoryGirl.create(:requirement) + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '7' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 7, NULL, '2014-06-19 20:51:48') + # ./spec/models/requirement_spec.rb:21:in `block (3 levels) in ' + + 16) Requirement#list_requirement_admins should return a list of met requirements, followed by unmet requirements if they exists + Failure/Error: @requirement = FactoryGirl.create(:requirement) + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '8' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 8, NULL, '2014-06-19 20:51:48') + # ./spec/models/requirement_spec.rb:21:in `block (3 levels) in ' + + 17) RequirementsController GET index is admin + Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '9' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 9, NULL, '2014-06-19 20:51:49') + # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' + + 18) RequirementsController GET index is admin + Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '10' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 10, NULL, '2014-06-19 20:51:49') + # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' + + 19) RequirementsController GET index is admin should populate an array of all requirements + Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") + ActiveRecord::RecordNotUnique: + Mysql2::Error: Duplicate entry '11' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 11, NULL, '2014-06-19 20:51:49') + # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' + + 20) ContactController POST create with valid attributes sends a message + Failure/Error: ActionMailer::Base.deliveries.last.subject.should eq('[Reservations Specs] ' + FactoryGirl.build(:message).subject) + + expected: "[Reservations Specs] Message" + got: "[Reservations] Message" + + (compared using ==) + # ./spec/controllers/contact_controller_spec.rb:33:in `block (4 levels) in ' + + 21) EquipmentModelsController GET index with admin user without show deleted without @category set should populate an array of all active equipment models + Failure/Error: expect(assigns(:equipment_models).size).to eq(2) + + expected: 2 + got: 3 + + (compared using ==) + # ./spec/controllers/equipment_models_controller_spec.rb:38:in `block (6 levels) in ' + + 22) EquipmentModelsController GET index with admin user with show deleted without @category set should populate an array of all equipment models + Failure/Error: expect(assigns(:equipment_models).size).to eq(3) + + expected: 3 + got: 4 + + (compared using ==) + # ./spec/controllers/equipment_models_controller_spec.rb:64:in `block (6 levels) in ' + + 23) EquipmentModelsController PUT update with admin user with valid attributes + Failure/Error: before { put :update, id: model, equipment_model: + NoMethodError: + undefined method `each' for nil:NilClass + # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' + # ./app/controllers/equipment_models_controller.rb:71:in `update' + # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' + + 24) EquipmentModelsController PUT update with admin user with valid attributes sets @equipment_model to selected model + Failure/Error: before { put :update, id: model, equipment_model: + NoMethodError: + undefined method `each' for nil:NilClass + # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' + # ./app/controllers/equipment_models_controller.rb:71:in `update' + # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' + + 25) EquipmentModelsController PUT update with admin user with valid attributes + Failure/Error: before { put :update, id: model, equipment_model: + NoMethodError: + undefined method `each' for nil:NilClass + # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' + # ./app/controllers/equipment_models_controller.rb:71:in `update' + # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' + + 26) EquipmentModelsController PUT update with admin user with valid attributes updates attributes + Failure/Error: before { put :update, id: model, equipment_model: + NoMethodError: + undefined method `each' for nil:NilClass + # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' + # ./app/controllers/equipment_models_controller.rb:71:in `update' + # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' + + 27) Announcements displays active announcements + Failure/Error: visit '/catalog' + NoMethodError: + undefined method `gsub' for nil:NilClass + # ./app/models/user.rb:105:in `search_ldap' + # ./app/controllers/users_controller.rb:54:in `new' + # ./spec/requests/announcements_spec.rb:7:in `block (2 levels) in ' + + 28) CatalogController PUT remove_from_cart invalid equipment_model selected should add logger error + Failure/Error: Rails.logger.should_receive(:error).with("Attempt to add invalid equipment model #{1}") + (#).error("Attempt to add invalid equipment model 1") + expected: 1 time with arguments: ("Attempt to add invalid equipment model 1") + received: 0 times with arguments: ("Attempt to add invalid equipment model 1") + # ./spec/controllers/catalog_controller_spec.rb:81:in `block (4 levels) in ' + + 29) CatalogController PUT add_to_cart invalid equipment_model selected should add logger error + Failure/Error: Rails.logger.should_receive(:error).with("Attempt to add invalid equipment model #{1}") + (#).error("Attempt to add invalid equipment model 1") + expected: 1 time with arguments: ("Attempt to add invalid equipment model 1") + received: 0 times with arguments: ("Attempt to add invalid equipment model 1") + # ./spec/controllers/catalog_controller_spec.rb:49:in `block (4 levels) in ' + + 30) CategoriesController GET index user is admin should populate an array of all categories if show deleted is true + Failure/Error: expect(assigns(:categories)).to eq([@category, @inactive_category]) + + expected: [#, #] + got: [#, #, #] + + (compared using ==) + + Diff: + @@ -1,3 +1,4 @@ + -[#, + +[#, + + #, + #] + # ./spec/controllers/categories_controller_spec.rb:23:in `block (4 levels) in ' + + 31) CategoriesController GET index user is admin should populate an array of active categories if show deleted is nil or false + Failure/Error: expect(assigns(:categories)).to eq([@category]) + + expected: [#] + got: [#, #] + + (compared using ==) + + Diff: + @@ -1,2 +1,2 @@ + -[#] + +[#, #] + # ./spec/controllers/categories_controller_spec.rb:26:in `block (4 levels) in ' + + 32) CategoriesController GET index user is not admin should populate an array of all categories if show deleted is true + Failure/Error: expect(assigns(:categories)).to eq([@category, @inactive_category]) + + expected: [#, #] + got: [#, #, #] + + (compared using ==) + + Diff: + @@ -1,3 +1,4 @@ + -[#, + +[#, + + #, + #] + # ./spec/controllers/categories_controller_spec.rb:42:in `block (4 levels) in ' + + 33) CategoriesController GET index user is not admin should populate an array of active categories if show deleted is nil or false + Failure/Error: expect(assigns(:categories)).to eq([@category]) + + expected: [#] + got: [#, #] + + (compared using ==) + + Diff: + @@ -1,2 +1,2 @@ + -[#] + +[#, #] + # ./spec/controllers/categories_controller_spec.rb:45:in `block (4 levels) in ' + + 34) AppConfigsController GET edit app_config does not exist yet should respond with 200 + Failure/Error: it { should respond_with(:success) } + Expected response to be a 200, but was 302 + # ./spec/controllers/app_configs_controller_spec.rb:43:in `block (4 levels) in ' + + 35) AppConfigsController POST update app config already exists user is admin assigns current configuration to @app_config + Failure/Error: expect(assigns(:app_config)).to eq(@app_config) + + expected: # + got: # + + (compared using ==) + + Diff: + @@ -1,2 +1,2 @@ + -# + +# + # ./spec/controllers/app_configs_controller_spec.rb:63:in `block (5 levels) in ' + + 36) AppConfigsController POST update app_config does not exist yet should respond with 200 + Failure/Error: it { should respond_with(:success) } + Expected response to be a 200, but was 302 + # ./spec/controllers/app_configs_controller_spec.rb:114:in `block (4 levels) in ' + + 37) Announcement has current scope + Failure/Error: passed = Announcement.create! starts_at: 1.day.ago, ends_at: 1.hour.ago + ActiveRecord::RecordInvalid: + Validation failed: Message can't be blank + # ./spec/models/announcement_spec.rb:6:in `block (2 levels) in ' + + 38) Announcement does not include ids passed in to current + Failure/Error: current1 = Announcement.create! starts_at: 1.hour.ago, ends_at: 1.day.from_now + ActiveRecord::RecordInvalid: + Validation failed: Message can't be blank + # ./spec/models/announcement_spec.rb:12:in `block (2 levels) in ' + + 39) Announcement includes current when nil is passed in + Failure/Error: current = Announcement.create! starts_at: 1.hour.ago, ends_at: 1.day.from_now + ActiveRecord::RecordInvalid: + Validation failed: Message can't be blank + # ./spec/models/announcement_spec.rb:18:in `block (2 levels) in ' + + 40) User#select_options should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] + Failure/Error: User.select_options.should == [["#{@user2.last_name}, #{@user2.first_name}", @user2.id],["#{@user1.last_name}, #{@user1.first_name}", @user1.id]] + expected: [["Greene, Jessica", 487], ["Smith, Joseph", 486]] + got: [["Greene, Jessica", 487], ["Smith, Joseph", 486], ["Spencer, Rafaela", 2], ["test, test", 1]] (using ==) + # ./spec/models/user_spec.rb:231:in `block (3 levels) in ' + + 41) EquipmentModel class methods #catalog_search Should not return any equipment_models without every query word in the name or description + Failure/Error: EquipmentModel.catalog_search("Craft beer sartorial four loko").should == [@another_model] + expected: [#, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] + got: [#, replacement_fee: #, max_per_user: 1, active: true, category_id: 1, created_at: "2014-06-19 20:25:03", updated_at: "2014-06-19 20:25:03", deleted_at: nil, photo_file_name: "epson-powerlite.jpg", photo_content_type: "image/jpeg", photo_file_size: 75765, photo_updated_at: "2014-06-19 20:25:02", documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 35, max_renewal_length: 27, renewal_days_before_due: 3646>, #, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] (using ==) + Diff: + @@ -1,2 +1,3 @@ + -[#, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] + +[#, replacement_fee: #, max_per_user: 1, active: true, category_id: 1, created_at: "2014-06-19 20:25:03", updated_at: "2014-06-19 20:25:03", deleted_at: nil, photo_file_name: "epson-powerlite.jpg", photo_content_type: "image/jpeg", photo_file_size: 75765, photo_updated_at: "2014-06-19 20:25:02", documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 35, max_renewal_length: 27, renewal_days_before_due: 3646>, + + #, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] + # ./spec/models/equipment_model_spec.rb:172:in `block (4 levels) in ' + +Finished in 1 minute 20.3 seconds +599 examples, 41 failures, 20 pending + +Failed examples: + +rspec ./spec/controllers/equipment_objects_controller_spec.rb:34 # EquipmentObjectsController GET index with admin user without show deleted without @equipment_model set should populate an array of all active equipment objects +rspec ./spec/controllers/equipment_objects_controller_spec.rb:59 # EquipmentObjectsController GET index with admin user with show deleted without @equipment_model set should populate an array of all equipment objects +rspec ./spec/models/reservation_spec.rb:28 # Reservation when valid should save +rspec ./spec/models/reservation_spec.rb:379 # Reservation with equipment model quantity problems should not save +rspec ./spec/models/reservation_spec.rb:211 # Reservation when user has overdue reservation should not save +rspec ./spec/models/reservation_spec.rb:276 # Reservation with equipment object/model matching problems should not save +rspec ./spec/models/reservation_spec.rb:93 # Reservation when empty should not save +rspec ./spec/models/reservation_spec.rb:117 # Reservation when empty updates with equipment model +rspec ./spec/models/reservation_spec.rb:343 # Reservation with category quantity problems should not save +rspec ./spec/models/reservation_spec.rb:153 # Reservation with past due date updates with fixed date +rspec ./spec/models/reservation_spec.rb:129 # Reservation with past due date should not save +rspec ./spec/models/reservation_spec.rb:309 # Reservation with duration problems should not save +rspec ./spec/models/reservation_spec.rb:165 # Reservation with blacked out start date should not save +rspec ./spec/models/requirement_spec.rb:8 # Requirement Validations has a working factory +rspec ./spec/models/requirement_spec.rb:28 # Requirement#list_requirement_admins should return a list of admins and contact info if no requirements have been met. +rspec ./spec/models/requirement_spec.rb:35 # Requirement#list_requirement_admins should return a list of met requirements, followed by unmet requirements if they exists +rspec ./spec/controllers/requirements_controller_spec.rb:19 # RequirementsController GET index is admin +rspec ./spec/controllers/requirements_controller_spec.rb:20 # RequirementsController GET index is admin +rspec ./spec/controllers/requirements_controller_spec.rb:22 # RequirementsController GET index is admin should populate an array of all requirements +rspec ./spec/controllers/contact_controller_spec.rb:32 # ContactController POST create with valid attributes sends a message +rspec ./spec/controllers/equipment_models_controller_spec.rb:34 # EquipmentModelsController GET index with admin user without show deleted without @category set should populate an array of all active equipment models +rspec ./spec/controllers/equipment_models_controller_spec.rb:59 # EquipmentModelsController GET index with admin user with show deleted without @category set should populate an array of all equipment models +rspec ./spec/controllers/equipment_models_controller_spec.rb:215 # EquipmentModelsController PUT update with admin user with valid attributes +rspec ./spec/controllers/equipment_models_controller_spec.rb:216 # EquipmentModelsController PUT update with admin user with valid attributes sets @equipment_model to selected model +rspec ./spec/controllers/equipment_models_controller_spec.rb:223 # EquipmentModelsController PUT update with admin user with valid attributes +rspec ./spec/controllers/equipment_models_controller_spec.rb:219 # EquipmentModelsController PUT update with admin user with valid attributes updates attributes +rspec ./spec/requests/announcements_spec.rb:4 # Announcements displays active announcements +rspec ./spec/controllers/catalog_controller_spec.rb:80 # CatalogController PUT remove_from_cart invalid equipment_model selected should add logger error +rspec ./spec/controllers/catalog_controller_spec.rb:48 # CatalogController PUT add_to_cart invalid equipment_model selected should add logger error +rspec ./spec/controllers/categories_controller_spec.rb:21 # CategoriesController GET index user is admin should populate an array of all categories if show deleted is true +rspec ./spec/controllers/categories_controller_spec.rb:25 # CategoriesController GET index user is admin should populate an array of active categories if show deleted is nil or false +rspec ./spec/controllers/categories_controller_spec.rb:40 # CategoriesController GET index user is not admin should populate an array of all categories if show deleted is true +rspec ./spec/controllers/categories_controller_spec.rb:44 # CategoriesController GET index user is not admin should populate an array of active categories if show deleted is nil or false +rspec ./spec/controllers/app_configs_controller_spec.rb:43 # AppConfigsController GET edit app_config does not exist yet should respond with 200 +rspec ./spec/controllers/app_configs_controller_spec.rb:61 # AppConfigsController POST update app config already exists user is admin assigns current configuration to @app_config +rspec ./spec/controllers/app_configs_controller_spec.rb:114 # AppConfigsController POST update app_config does not exist yet should respond with 200 +rspec ./spec/models/announcement_spec.rb:5 # Announcement has current scope +rspec ./spec/models/announcement_spec.rb:11 # Announcement does not include ids passed in to current +rspec ./spec/models/announcement_spec.rb:17 # Announcement includes current when nil is passed in +rspec ./spec/models/user_spec.rb:228 # User#select_options should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] +rspec ./spec/models/equipment_model_spec.rb:169 # EquipmentModel class methods #catalog_search Should not return any equipment_models without every query word in the name or description + +Randomized with seed 50675 + From bf81e1cf65c333704746a5535f69039aa67251d5 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Thu, 19 Jun 2014 22:24:15 -0400 Subject: [PATCH 02/26] styling progress --- .../equipment_models/_show.css.scss | 32 +++++++++++++- .../equipment_models_controller.rb | 3 +- app/views/equipment_models/_calendar.html.erb | 44 ++++++++++++++++--- app/views/equipment_models/show.html.erb | 3 +- 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index f518f9957..f8631d1e2 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -1,3 +1,33 @@ + +$border-att: 1px solid darken($bodyBackground, 20%); + +#calendar_table { + width: 100%; + table-layout:fixed; +} + +.item_reservation { + overflow: hidden; + z-index: 100; + background-color: red; +} + +td.calendar_cell { + border-left: $border-att; + border-right: $border-att; + width: 14%; +} + +td.day { + border-radius:3px; + border-top: $border-att; + } + + +td.reservation { + border-bottom: $border-att; +} + .progress { margin-bottom: 0; } @@ -69,4 +99,4 @@ a.not-qualified-icon-em { text-decoration: none; color: $btnWarningBackground; } -} \ No newline at end of file +} diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 2109f0bcc..25f82284a 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -29,8 +29,7 @@ def show @model_reservations = Reservation.active.for_eq_model @equipment_model @date = Date.today @beginning = Date.today.beginning_of_week(:sunday) - binding.pry - render 'calendar' + #binding.pry end diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index d097a7f37..8af1a4e68 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,8 +1,38 @@ -
- -<% for d in @beginning..@beginning+7.day %> -
- <%= d.day %> -
-<% end %> +
+ + + + + + + + + + + + <% for d in @beginning...(@beginning+7.day) %> + + <% end %> + + + <% for d in @beginning...(@beginning+7.day) %> + + <% end %> + +
SunMonTueWedThuFriSat
+ <%= d.day %> +
+ <% @model_reservations.each do |r| %> + + <% if r.start_date.to_date == d %> + <% if r.equipment_object %> + <% label = r.equipment_object.name %> + <% else %> + <% label = 'Reserveddddddddddddddddddddd' %> + <% end %> + <%= label %> + <% end %> + + <% end %> +
diff --git a/app/views/equipment_models/show.html.erb b/app/views/equipment_models/show.html.erb index c506955ca..f74b190b1 100644 --- a/app/views/equipment_models/show.html.erb +++ b/app/views/equipment_models/show.html.erb @@ -2,8 +2,6 @@ <% subtitle Category.find(@equipment_model.category_id).name %> - <%= render :partial => 'calendar' %> -
@@ -28,6 +26,7 @@ <% end %>
+ <%= render :partial => 'calendar' %>
From 59513cd6589d1a0b2786d62b14d01c40ff7dfe09 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Thu, 19 Jun 2014 22:54:20 -0400 Subject: [PATCH 03/26] converted to divs --- .../equipment_models/_show.css.scss | 34 ++++---------- app/views/equipment_models/_calendar.html.erb | 46 ++++++------------- 2 files changed, 25 insertions(+), 55 deletions(-) diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index f8631d1e2..dccdb6d92 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -1,33 +1,19 @@ $border-att: 1px solid darken($bodyBackground, 20%); -#calendar_table { - width: 100%; - table-layout:fixed; -} - -.item_reservation { - overflow: hidden; - z-index: 100; - background-color: red; -} - -td.calendar_cell { - border-left: $border-att; - border-right: $border-att; - width: 14%; -} - -td.day { - border-radius:3px; - border-top: $border-att; +.reservation{ + white-space:nowrap; + display: block; + } + +.calendar_cell { + border: $border-att; + width: 13%; + display: inline-block; + vertical-align:top; } -td.reservation { - border-bottom: $border-att; -} - .progress { margin-bottom: 0; } diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 8af1a4e68..a0a080847 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,38 +1,22 @@
- - - - - - - - - - - - <% for d in @beginning...(@beginning+7.day) %> - - <% end %> - - - <% for d in @beginning...(@beginning+7.day) %> - + <% end %> - -
SunMonTueWedThuFriSat
- <%= d.day %> -
+
+
    + <% for d in @beginning...(@beginning+7.day) %> +
  • + <%= d.day %> +
      <% @model_reservations.each do |r| %> - <% if r.start_date.to_date == d %> <% if r.equipment_object %> - <% label = r.equipment_object.name %> - <% else %> - <% label = 'Reserveddddddddddddddddddddd' %> - <% end %> - <%= label %> - <% end %> - + <% label = r.equipment_object.name %> + <% else %> + <% label = 'Reserveddddddd' %> + <% end %> +
    • <%= label %>
    • + <% end %> <% end %> -
+ +
From d36143a6f9bf6d261f3c20daabde4d2d66e77022 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Thu, 19 Jun 2014 23:42:01 -0400 Subject: [PATCH 04/26] styling mostly ok, to do add jquery to extend visual block to due date --- app/assets/javascripts/application.js | 14 ++++++++++++++ .../stylesheets/equipment_models/_show.css.scss | 12 ++++++++++++ app/views/equipment_models/_calendar.html.erb | 7 ++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4b47c77aa..5151dc659 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -106,8 +106,22 @@ } }; +function equalHeight(elements,res_div) { + base_height = elements.height(); + max_height = 0; + res_div.each(function() { + thisHeight = $(this).height(); + if(thisHeight > max_height) { + max_height = thisHeight; + } + }); + elements.height(max_height+base_height); +} + $(document).ready(function() { + equalHeight($('.calendar_cell'),$('.res_div')); + $('.checkin-click').click( function() { var box = $(this).find(":checkbox"); box.prop("checked", !box.prop("checked")); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index dccdb6d92..23b90db43 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -4,8 +4,20 @@ $border-att: 1px solid darken($bodyBackground, 20%); .reservation{ white-space:nowrap; display: block; + background-color:red; + width: 200px; + z-index: 100; } +ul.res{ + margin-left: 1px; +} + +.res_div{ + position:absolute; + z-index:3; +} + .calendar_cell { border: $border-att; width: 13%; diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index a0a080847..90234d814 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,10 +1,11 @@
-
+
    <% for d in @beginning...(@beginning+7.day) %>
  • <%= d.day %> -
      +
      +
        <% @model_reservations.each do |r| %> <% if r.start_date.to_date == d %> <% if r.equipment_object %> @@ -15,7 +16,7 @@
      • <%= label %>
      • <% end %> <% end %> -
      +
<% end %>
From 8e83cf99db1cc89660f9ec3cca66649e68a65300 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 20 Jun 2014 12:14:43 -0400 Subject: [PATCH 05/26] what --- app/assets/javascripts/application.js | 28 ++++++++++++++++++- .../equipment_models_controller.rb | 13 +++++++-- app/views/equipment_models/_calendar.html.erb | 21 +++++--------- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 5151dc659..3d3136ed6 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -119,9 +119,35 @@ function equalHeight(elements,res_div) { } $(document).ready(function() { - + //$('#reservation-calendar').ready(function() { + var reservations = $('#res-data').data('url'); + var week_start = new Date($('#res-data').data('day')); + console.log(week_start); + for(var d = 0; d < reservations.length; d++) { + var end = new Date (reservations[d].end); + var start = new Date (reservations[d].start); + var week_end = new Date(); + week_end.setDate(week_start.getDate() + 7); + if ((start < week_end) && (end >= week_start)) { + //draw shit + var begin_date = ((week_start > start) ? week_start : start) + var end_date = ((week_end < end) ? week_end : end); + var ul = $('.'+begin_date.toISOString().substring(0,10)).children().children(); + var length = (end_date.getTime() - begin_date.getTime())/86400000; + console.log("start date" + begin_date); + console.log("end date: " + end_date); + console.log(length); + ul.append("
  • "+reservations[d].name+"
  • "); + + + } + } + equalHeight($('.calendar_cell'),$('.res_div')); + //}); + + $('.checkin-click').click( function() { var box = $(this).find(":checkbox"); box.prop("checked", !box.prop("checked")); diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 25f82284a..d9f7f97c7 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -27,9 +27,16 @@ def index def show @associated_equipment_models = @equipment_model.associated_equipment_models.sample(6) @model_reservations = Reservation.active.for_eq_model @equipment_model - @date = Date.today - @beginning = Date.today.beginning_of_week(:sunday) - #binding.pry + @reservation_data = [] + @model_reservations.each do |r| + @reservation_data << { + name: (r.equipment_object ? r.equipment_object.name : "Reserved"), + start: r.start_date, end: r.due_date, + path: reservation_path(r)} + end + @date = Time.current.to_date + @beginning = @date.beginning_of_week(:sunday) + binding.pry end diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 90234d814..fe849bcdd 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,22 +1,15 @@
    -
    +
    + <%= content_tag "div", id: "res-data", data:{url:@reservation_data, day:(@beginning.to_date)} do %> + <% end %>
      <% for d in @beginning...(@beginning+7.day) %> -
    • +
    • <%= d.day %>
      -
        - <% @model_reservations.each do |r| %> - <% if r.start_date.to_date == d %> - <% if r.equipment_object %> - <% label = r.equipment_object.name %> - <% else %> - <% label = 'Reserveddddddd' %> - <% end %> -
      • <%= label %>
      • - <% end %> - <% end %> -
      +
        +
      +
    <% end %>
    From 622f1adbe95cf6e10271933d633aff2fd3a2a205 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 20 Jun 2014 12:30:38 -0400 Subject: [PATCH 06/26] dynamic width --- app/assets/javascripts/application.js | 9 ++++----- app/controllers/equipment_models_controller.rb | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 3d3136ed6..02073a69e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -122,7 +122,7 @@ $(document).ready(function() { //$('#reservation-calendar').ready(function() { var reservations = $('#res-data').data('url'); var week_start = new Date($('#res-data').data('day')); - console.log(week_start); + var width = $('.calendar_cell').width(); for(var d = 0; d < reservations.length; d++) { var end = new Date (reservations[d].end); var start = new Date (reservations[d].start); @@ -134,10 +134,9 @@ $(document).ready(function() { var end_date = ((week_end < end) ? week_end : end); var ul = $('.'+begin_date.toISOString().substring(0,10)).children().children(); var length = (end_date.getTime() - begin_date.getTime())/86400000; - console.log("start date" + begin_date); - console.log("end date: " + end_date); - console.log(length); - ul.append("
  • "+reservations[d].name+"
  • "); + var new_block = $("
  • "+reservations[d].name+"
  • "); + new_block.width((length + 1)* width); + ul.append(new_block); } diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index d9f7f97c7..3cd4dfd4c 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -36,7 +36,7 @@ def show end @date = Time.current.to_date @beginning = @date.beginning_of_week(:sunday) - binding.pry + #binding.pry end From f6abdd6ccbc56c404d58654557d32bd4f12b44f4 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 20 Jun 2014 14:07:12 -0400 Subject: [PATCH 07/26] rework --- app/assets/javascripts/application.js | 38 +++++++------------ .../equipment_models/_show.css.scss | 17 ++------- .../equipment_models_controller.rb | 2 +- app/views/equipment_models/_calendar.html.erb | 12 +++--- 4 files changed, 23 insertions(+), 46 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 02073a69e..807575081 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -106,23 +106,11 @@ } }; -function equalHeight(elements,res_div) { - base_height = elements.height(); - max_height = 0; - res_div.each(function() { - thisHeight = $(this).height(); - if(thisHeight > max_height) { - max_height = thisHeight; - } - }); - elements.height(max_height+base_height); -} - $(document).ready(function() { - //$('#reservation-calendar').ready(function() { + $('#reservation-calendar').ready(function() { var reservations = $('#res-data').data('url'); var week_start = new Date($('#res-data').data('day')); - var width = $('.calendar_cell').width(); + var max = $('#res-data').data('max'); for(var d = 0; d < reservations.length; d++) { var end = new Date (reservations[d].end); var start = new Date (reservations[d].start); @@ -132,20 +120,20 @@ $(document).ready(function() { //draw shit var begin_date = ((week_start > start) ? week_start : start) var end_date = ((week_end < end) ? week_end : end); - var ul = $('.'+begin_date.toISOString().substring(0,10)).children().children(); - var length = (end_date.getTime() - begin_date.getTime())/86400000; - var new_block = $("
  • "+reservations[d].name+"
  • "); - new_block.width((length + 1)* width); - ul.append(new_block); - - + for (var date = begin_date; date <= end_date; date.setDate(date.getDate()+1)) { + var cell = $('.'+date.toISOString().substring(0,10)); + var val = parseInt(cell.children('.num').children()[0].innerHTML) - 1; + var red = (255 - val*255/max).toString(); + var green = (val*255/max).toString(); + console.log(red + " green " + green); + cell.css('background-color','rgba('+red+','+green+',0,0.25)'); + console.log(cell.css('background-color')); + cell.children('.num').children()[0].innerHTML = val; + } } } - equalHeight($('.calendar_cell'),$('.res_div')); - - //}); - + }); $('.checkin-click').click( function() { var box = $(this).find(":checkbox"); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 23b90db43..728e3bfb3 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -1,21 +1,9 @@ $border-att: 1px solid darken($bodyBackground, 20%); -.reservation{ - white-space:nowrap; - display: block; - background-color:red; - width: 200px; - z-index: 100; - } - -ul.res{ - margin-left: 1px; -} +.num { + text-align:center; -.res_div{ - position:absolute; - z-index:3; } .calendar_cell { @@ -23,6 +11,7 @@ ul.res{ width: 13%; display: inline-block; vertical-align:top; + background-color: rgba(0,255,0,0.25); } diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 3cd4dfd4c..6b0d6282c 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -35,7 +35,7 @@ def show path: reservation_path(r)} end @date = Time.current.to_date - @beginning = @date.beginning_of_week(:sunday) + @max = @equipment_model.equipment_objects.count #binding.pry end diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index fe849bcdd..a6c71ff4f 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,15 +1,15 @@
    - <%= content_tag "div", id: "res-data", data:{url:@reservation_data, day:(@beginning.to_date)} do %> + <%= content_tag "div", id: "res-data", data:{url:@reservation_data, day:(@date.to_date), max:@max} do %> <% end %>
      - <% for d in @beginning...(@beginning+7.day) %> + <% for d in @date...(@date+7.day) %>
    • - <%= d.day %> -
      -
        -
      + <%= "#{d.day} - #{d.to_time.strftime('%a')}" %> +
      +

      <%= @max %>

      + <% end %>
    From 6125faa3ce5d5df7d1ef4d8614270e4dda728d15 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 20 Jun 2014 17:02:40 -0400 Subject: [PATCH 08/26] organizing code --- app/assets/javascripts/application.js | 30 ++-------------- app/assets/javascripts/calendar.js | 36 +++++++++++++++++++ .../equipment_models/_show.css.scss | 8 +++-- app/views/equipment_models/_calendar.html.erb | 5 ++- app/views/equipment_models/calendar.js | 1 + app/views/equipment_models/show.html.erb | 4 ++- 6 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 app/assets/javascripts/calendar.js create mode 100644 app/views/equipment_models/calendar.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 807575081..2a4851228 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -24,6 +24,7 @@ //= require variables.js //= require select2 //= require_self +//= require calendar.js function truncate() { if ($(".caption_cat").length) { @@ -107,34 +108,7 @@ }; $(document).ready(function() { - $('#reservation-calendar').ready(function() { - var reservations = $('#res-data').data('url'); - var week_start = new Date($('#res-data').data('day')); - var max = $('#res-data').data('max'); - for(var d = 0; d < reservations.length; d++) { - var end = new Date (reservations[d].end); - var start = new Date (reservations[d].start); - var week_end = new Date(); - week_end.setDate(week_start.getDate() + 7); - if ((start < week_end) && (end >= week_start)) { - //draw shit - var begin_date = ((week_start > start) ? week_start : start) - var end_date = ((week_end < end) ? week_end : end); - for (var date = begin_date; date <= end_date; date.setDate(date.getDate()+1)) { - var cell = $('.'+date.toISOString().substring(0,10)); - var val = parseInt(cell.children('.num').children()[0].innerHTML) - 1; - var red = (255 - val*255/max).toString(); - var green = (val*255/max).toString(); - console.log(red + " green " + green); - cell.css('background-color','rgba('+red+','+green+',0,0.25)'); - console.log(cell.css('background-color')); - cell.children('.num').children()[0].innerHTML = val; - } - } - } - - }); - + $('.checkin-click').click( function() { var box = $(this).find(":checkbox"); box.prop("checked", !box.prop("checked")); diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js new file mode 100644 index 000000000..02cb2de16 --- /dev/null +++ b/app/assets/javascripts/calendar.js @@ -0,0 +1,36 @@ +function decCellValue(cell) { + var obj = cell.children('.num').children()[0]; + obj.innerHTML = parseInt(obj.innerHTML) - 1; +}; + +$('#reservation-calendar').ready(function() { + var reservations = $('#res-data').data('url'); + var week_start = new Date($('#res-data').data('day')); + var max = $('#res-data').data('max'); + for(var d = 0; d < reservations.length; d++) { + var end = new Date (reservations[d].end); + var start = new Date (reservations[d].start); + var week_end = new Date(); + week_end.setDate(week_start.getDate() + 7); + if ((start < week_end) && (end >= week_start)) { + //for each reservation, decrement availability per day + var begin_date = ((week_start > start) ? week_start : start); + var end_date = ((week_end < end) ? week_end : end); + for (var date = begin_date; + date <= end_date; + date.setDate(date.getDate()+1)) { + var cell = $('.'+date.toISOString().substring(0,10)); + decCellValue(cell); + } + } + } + $('.calendar_cell').cells.each(function() { + var val = parseInt($(this).children('.num').children()[0].innerHTML); + var red = Math.min(Math.floor(510 - val*510/max),255).toString(); + var green = Math.min(Math.floor(val*510/max),255).toString(); + var color = 'rgba(' + red + ',' + green + ',0,0.25)'; + $(this).css("background-color",color); + }); + + }); + diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 728e3bfb3..94b16f67d 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -1,7 +1,7 @@ $border-att: 1px solid darken($bodyBackground, 20%); -.num { +.num,.head { text-align:center; } @@ -11,9 +11,13 @@ $border-att: 1px solid darken($bodyBackground, 20%); width: 13%; display: inline-block; vertical-align:top; - background-color: rgba(0,255,0,0.25); + background-color: rgba(0,255,0,0.25); } +.calendar_cell:hover{ + background-color: red !important; + +} .progress { margin-bottom: 0; diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index a6c71ff4f..b137f8525 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -5,11 +5,14 @@
      <% for d in @date...(@date+7.day) %>
    • - <%= "#{d.day} - #{d.to_time.strftime('%a')}" %> +
      + <%= "#{d.day} - #{d.to_time.strftime('%a')}" %> +

      <%= @max %>

      + <% end %>
    diff --git a/app/views/equipment_models/calendar.js b/app/views/equipment_models/calendar.js new file mode 100644 index 000000000..9daeafb98 --- /dev/null +++ b/app/views/equipment_models/calendar.js @@ -0,0 +1 @@ +test diff --git a/app/views/equipment_models/show.html.erb b/app/views/equipment_models/show.html.erb index f74b190b1..8c63310f6 100644 --- a/app/views/equipment_models/show.html.erb +++ b/app/views/equipment_models/show.html.erb @@ -26,7 +26,6 @@ <% end %>
    - <%= render :partial => 'calendar' %>
    @@ -121,6 +120,9 @@
    + + <%= render :partial => 'calendar' %> +

    From a8a402a01ceb21e4b4a00185295181914567c323 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 13:40:39 -0400 Subject: [PATCH 09/26] calendar render entirely in js --- app/assets/javascripts/calendar.js | 71 +++++++++++++++---- .../equipment_models/_show.css.scss | 6 +- .../equipment_models_controller.rb | 4 +- app/views/equipment_models/_calendar.html.erb | 18 ++--- 4 files changed, 69 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 02cb2de16..53fada25e 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -3,11 +3,27 @@ function decCellValue(cell) { obj.innerHTML = parseInt(obj.innerHTML) - 1; }; -$('#reservation-calendar').ready(function() { - var reservations = $('#res-data').data('url'); - var week_start = new Date($('#res-data').data('day')); - var max = $('#res-data').data('max'); - for(var d = 0; d < reservations.length; d++) { +function dateToRubyString(date) { + return date.toISOString().substring(0,10); +}; + +function dateToHeading(date) { + var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun']; + var day = days[date.getDay()]; + return date.getDate().toString() + " - " + day; +}; + +function renderCalendar(reservations, week_start, max) { + //set initial values and date ids + var date = new Date(week_start.getTime()); + $('.calendar_cell').each(function() { + $(this).children('.head').children()[0].innerHTML = dateToHeading(date); + $(this).children('.num').children()[0].innerHTML = max.toString(); + $(this).attr('id',dateToRubyString(date)); + date.setDate(date.getDate()+1); + }); + //set cell values based on reservations + for(var d = 0; d < reservations.length; d++) { var end = new Date (reservations[d].end); var start = new Date (reservations[d].start); var week_end = new Date(); @@ -19,18 +35,43 @@ $('#reservation-calendar').ready(function() { for (var date = begin_date; date <= end_date; date.setDate(date.getDate()+1)) { - var cell = $('.'+date.toISOString().substring(0,10)); - decCellValue(cell); + decCellValue($('#'+dateToRubyString(date))); } } - } - $('.calendar_cell').cells.each(function() { - var val = parseInt($(this).children('.num').children()[0].innerHTML); - var red = Math.min(Math.floor(510 - val*510/max),255).toString(); - var green = Math.min(Math.floor(val*510/max),255).toString(); - var color = 'rgba(' + red + ',' + green + ',0,0.25)'; - $(this).css("background-color",color); - }); + } + //color cells appropriately + $('.calendar_cell').each(function() { + var val = parseInt($(this).children('.num').children()[0].innerHTML); + var red = Math.min(Math.floor(510 - val*510/max),255).toString(); + var green = Math.min(Math.floor(val*510/max),255).toString(); + var color = 'rgba(' + red + ',' + green + ',0,0.5)'; + $(this).css("background-color",color); }); +}; + +$('#reservation-calendar').ready(function() { + var reservations = $('#res-data').data('url'); + var week_start = new Date($('#res-data').data('day')); + var max = $('#res-data').data('max'); + renderCalendar(reservations,week_start,max); + +$('.calendar_cell').click(function() { + //set cart dates to day clicked + +}); + +$('.forward1').click(function() { + console.log('clicked!'); + var reservations = $('#res-data').data('url'); + var week_start = new Date($('.calendar_cell').first().attr('id')); + var max = $('#res-data').data('max') + week_start.setDate(week_start.getDate() + 1); + renderCalendar(reservations,week_start,max); + + +}); + + + }); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 94b16f67d..5f8cedbb3 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -11,12 +11,12 @@ $border-att: 1px solid darken($bodyBackground, 20%); width: 13%; display: inline-block; vertical-align:top; - background-color: rgba(0,255,0,0.25); + background-color: rgba(0,255,0,0.5); + opacity: 0.8 } .calendar_cell:hover{ - background-color: red !important; - + opacity: 1.0; } .progress { diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 6b0d6282c..a42c5c811 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -30,9 +30,7 @@ def show @reservation_data = [] @model_reservations.each do |r| @reservation_data << { - name: (r.equipment_object ? r.equipment_object.name : "Reserved"), - start: r.start_date, end: r.due_date, - path: reservation_path(r)} + start: r.start_date, end: r.due_date} end @date = Time.current.to_date @max = @equipment_model.equipment_objects.count diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index b137f8525..e8536e56e 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -4,16 +4,16 @@ <% end %>
      <% for d in @date...(@date+7.day) %> -
    • -
      - <%= "#{d.day} - #{d.to_time.strftime('%a')}" %> -
      -
      -

      <%= @max %>

      -
      - - +
    • +
      +

      +
      +
      +

      +
      +
    • <% end %>
    +
    forward1
    From a719a9925f3795e03d8babf290d2046088fc3be7 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 13:50:56 -0400 Subject: [PATCH 10/26] fancify --- app/assets/javascripts/calendar.js | 34 +++++++++---------- app/views/equipment_models/_calendar.html.erb | 24 ++++++------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 53fada25e..8fb9c1a55 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -51,27 +51,27 @@ function renderCalendar(reservations, week_start, max) { }; -$('#reservation-calendar').ready(function() { - var reservations = $('#res-data').data('url'); - var week_start = new Date($('#res-data').data('day')); - var max = $('#res-data').data('max'); - renderCalendar(reservations,week_start,max); +function shiftCalendar(offset) { + var reservations = $('#res-data').data('url'); + var week_start = new Date($('.calendar_cell').first().attr('id')); + var max = $('#res-data').data('max'); + week_start.setDate(week_start.getDate() + offset); + renderCalendar(reservations,week_start,max); +}; -$('.calendar_cell').click(function() { - //set cart dates to day clicked -}); +$('#reservation-calendar').ready(function() { + + shiftCalendar(0); -$('.forward1').click(function() { - console.log('clicked!'); - var reservations = $('#res-data').data('url'); - var week_start = new Date($('.calendar_cell').first().attr('id')); - var max = $('#res-data').data('max') - week_start.setDate(week_start.getDate() + 1); - renderCalendar(reservations,week_start,max); + $('.calendar_cell').click(function() { + //set cart dates to day clicked + }); + $('.forward1').click(function() { + shiftCalendar(1); + }); -}); - }); +}); diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index e8536e56e..155853c46 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -2,18 +2,18 @@
    <%= content_tag "div", id: "res-data", data:{url:@reservation_data, day:(@date.to_date), max:@max} do %> <% end %> -
      - <% for d in @date...(@date+7.day) %> -
    • -
      -

      -
      -
      -

      -
      -
    • - <% end %> -
    +
      +
    • + <% for d in 0...6 %> +

      +

      +
    • +
    • + <% end %> +

      +

      +
    • +
    forward1
    From 0c0934437aee04004d52fe4089878fc041ba7510 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 15:17:13 -0400 Subject: [PATCH 11/26] i hate time zones --- app/assets/javascripts/calendar.js | 29 ++++++++++++++++++- .../equipment_models/_show.css.scss | 8 +++++ app/views/equipment_models/_calendar.html.erb | 16 ++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 8fb9c1a55..341295b85 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -22,6 +22,11 @@ function renderCalendar(reservations, week_start, max) { $(this).attr('id',dateToRubyString(date)); date.setDate(date.getDate()+1); }); + var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; + + $('.month').children()[0].innerHTML = "Availability: " + months[date.getMonth()] + " " + date.getFullYear().toString(); + + //set cell values based on reservations for(var d = 0; d < reservations.length; d++) { var end = new Date (reservations[d].end); @@ -54,8 +59,19 @@ function renderCalendar(reservations, week_start, max) { function shiftCalendar(offset) { var reservations = $('#res-data').data('url'); var week_start = new Date($('.calendar_cell').first().attr('id')); + var today = new Date(); + today.setHours(0,0,0,0); var max = $('#res-data').data('max'); + + console.log(week_start + " " + today); week_start.setDate(week_start.getDate() + offset); + + console.log(week_start + " " + today); + if (week_start < today) { + week_start.setTime(today.getTime()); + } + + console.log(week_start + " " + today); renderCalendar(reservations,week_start,max); }; @@ -68,10 +84,21 @@ $('#reservation-calendar').ready(function() { //set cart dates to day clicked }); - $('.forward1').click(function() { + $('.f_day').click(function() { shiftCalendar(1); }); + $('.b_day').click(function() { + shiftCalendar(-1); + }); + + $('.f_week').click(function() { + shiftCalendar(7); + }); + + $('.b_week').click(function() { + shiftCalendar(-7); + }); }); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 5f8cedbb3..c4569ab29 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -19,6 +19,14 @@ $border-att: 1px solid darken($bodyBackground, 20%); opacity: 1.0; } +.c-left { + float: left; +} + +.c-right { + float: right; +} + .progress { margin-bottom: 0; } diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 155853c46..c7accde48 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,7 +1,10 @@
    - <%= content_tag "div", id: "res-data", data:{url:@reservation_data, day:(@date.to_date), max:@max} do %> + <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date, max:@max} do %> <% end %> + +

    +
    • <% for d in 0...6 %> @@ -14,6 +17,15 @@

    -
    forward1
    + + +
    + back a week + back 1 day +
    +
    + forward 1 day + forward 1 week +
    From a9079f3b1d9a1cabd4a2407b04d572724e7abc32 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 18:30:38 -0400 Subject: [PATCH 12/26] time zones fixed, dumb chrome bug --- app/assets/javascripts/calendar.js | 3 +-- app/views/equipment_models/_calendar.html.erb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 341295b85..90d963942 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -59,8 +59,7 @@ function renderCalendar(reservations, week_start, max) { function shiftCalendar(offset) { var reservations = $('#res-data').data('url'); var week_start = new Date($('.calendar_cell').first().attr('id')); - var today = new Date(); - today.setHours(0,0,0,0); + var today = new Date($('#res-data').data('today')); var max = $('#res-data').data('max'); console.log(week_start + " " + today); diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index c7accde48..ee72b3296 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,6 +1,6 @@
    - <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date, max:@max} do %> + <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date.to_s, max:@max} do %> <% end %>

    From f405d66c59af0ae72a211c09e0f2625068c94385 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 19:39:25 -0400 Subject: [PATCH 13/26] refactoring show view --- app/assets/javascripts/calendar.js | 16 ++--- .../equipment_models/_show.css.scss | 15 ++-- .../equipment_models_controller.rb | 5 ++ app/views/equipment_models/_calendar.html.erb | 8 +-- app/views/equipment_models/_span2.html.erb | 33 +++++++++ app/views/equipment_models/show.html.erb | 68 +------------------ 6 files changed, 63 insertions(+), 82 deletions(-) create mode 100644 app/views/equipment_models/_span2.html.erb diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 90d963942..7a4bb66f1 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -9,8 +9,8 @@ function dateToRubyString(date) { function dateToHeading(date) { var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun']; - var day = days[date.getDay()]; - return date.getDate().toString() + " - " + day; + var day = days[date.getUTCDay()]; + return date.getUTCDate().toString() + " - " + day; }; function renderCalendar(reservations, week_start, max) { @@ -24,7 +24,7 @@ function renderCalendar(reservations, week_start, max) { }); var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; - $('.month').children()[0].innerHTML = "Availability: " + months[date.getMonth()] + " " + date.getFullYear().toString(); + $('.month').children()[0].innerHTML = "Availability: " + months[week_start.getMonth()] + " " + date.getFullYear().toString(); //set cell values based on reservations @@ -52,6 +52,11 @@ function renderCalendar(reservations, week_start, max) { var green = Math.min(Math.floor(val*510/max),255).toString(); var color = 'rgba(' + red + ',' + green + ',0,0.5)'; $(this).css("background-color",color); + + if ($(this).attr('id') == $('#res-data').data('today')) { + $(this).addClass('today'); + } + }); }; @@ -61,16 +66,11 @@ function shiftCalendar(offset) { var week_start = new Date($('.calendar_cell').first().attr('id')); var today = new Date($('#res-data').data('today')); var max = $('#res-data').data('max'); - - console.log(week_start + " " + today); week_start.setDate(week_start.getDate() + offset); - - console.log(week_start + " " + today); if (week_start < today) { week_start.setTime(today.getTime()); } - console.log(week_start + " " + today); renderCalendar(reservations,week_start,max); }; diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index c4569ab29..688476478 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -3,18 +3,28 @@ $border-att: 1px solid darken($bodyBackground, 20%); .num,.head { text-align:center; +} +#calendar-ul { + margin: 0px; } .calendar_cell { border: $border-att; + border-radius: 3px; width: 13%; display: inline-block; vertical-align:top; background-color: rgba(0,255,0,0.5); - opacity: 0.8 + opacity: 0.8; + padding-top: 3px; + padding-bottom: 5px; } +.today { + border: 2px solid darken($bodyBackground, 30%); +} + .calendar_cell:hover{ opacity: 1.0; } @@ -27,9 +37,6 @@ $border-att: 1px solid darken($bodyBackground, 20%); float: right; } -.progress { - margin-bottom: 0; -} .btn-large { float: right; } diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index a42c5c811..48e6472b0 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -34,6 +34,11 @@ def show end @date = Time.current.to_date @max = @equipment_model.equipment_objects.count + + @restricted = @equipment_model.model_restricted?(cart.reserver_id) + @blacked_out_start = Blackout.hard_blackout_exists_on_date(cart.start_date) + @blacked_out_end = Blackout.hard_blackout_exists_on_date(cart.due_date) + #binding.pry end diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index ee72b3296..92ce1b3ca 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,19 +1,18 @@ -
    <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date.to_s, max:@max} do %> <% end %>

    -
      +
      • <% for d in 0...6 %> -

        +

      • <% end %> -

        +

      @@ -28,4 +27,3 @@ forward 1 week
    -
    diff --git a/app/views/equipment_models/_span2.html.erb b/app/views/equipment_models/_span2.html.erb new file mode 100644 index 000000000..a48942ebc --- /dev/null +++ b/app/views/equipment_models/_span2.html.erb @@ -0,0 +1,33 @@ + <% if @restricted || @blacked_out_start || @blacked_out_end %> + <%= link_to "#qualifications_modal", + class: 'not-qualified-icon-em', + rel: "tooltip", + title: 'Not ' + (@restricted ? "Qualified" : "Available") +" (click for more info)", + :"data-toggle" => 'modal' do %> + + <% end %> + <%= button_tag "Add to Cart", remote: true, class: 'btn btn-primary btn-large disabled' %> + + <% else %> + + <%= link_to "Add to Cart", {:url => add_to_cart_path(@equipment_model)}, + :href => add_to_cart_path(@equipment_model), + :method => :put, :remote => true, :class => 'btn btn-primary btn-large' %> + <% end %> + diff --git a/app/views/equipment_models/show.html.erb b/app/views/equipment_models/show.html.erb index 8c63310f6..d42b96da0 100644 --- a/app/views/equipment_models/show.html.erb +++ b/app/views/equipment_models/show.html.erb @@ -30,74 +30,13 @@
    -

    - <%= @equipment_model.num_available(cart.start_date, cart.due_date) || "0"%> available of <%= @equipment_model.equipment_objects.size %> -

    -

    - <%= content_tag :div, class: "progress #{progress_color}" do %> - <%= content_tag :div, nil, class: 'bar', style: "width: 0%;", :"data-percentage" => bar_progress.chop %> - <% end %> -

    -

    from <%= cart.start_date.strftime("%b %d, %Y") %> – <%= cart.due_date.strftime("%b %d, %Y") %>

    + <%= render :partial => 'calendar' %>
    - -
    <%# TODO: Not super DRY right now, will refactor in the future %> - <% if @equipment_model.model_restricted?(cart.reserver_id) %> - <%= link_to "#qualifications_modal", class: 'not-qualified-icon-em', rel: "tooltip", title: "Not Qualified (click for more info)", :"data-toggle" => 'modal' do %> - - <% end %> - - <%= button_tag "Add to Cart", remote: true, class: 'btn btn-primary btn-large disabled' %> - - - <% elsif Blackout.hard_blackout_exists_on_date(cart.start_date) %> - <%= link_to "#qualifications_modal", class: 'not-qualified-icon-em', rel: "tooltip", title: "Not Available (click for more info)", :"data-toggle" => 'modal' do %> - - <% end %> - - <%= button_tag "Add to Cart", remote: true, class: 'btn btn-primary btn-large disabled' %> - - <% elsif Blackout.hard_blackout_exists_on_date(cart.due_date) %> - - <% else %> - - <%= link_to "Add to Cart", {:url => add_to_cart_path(@equipment_model)}, - :href => add_to_cart_path(@equipment_model), - :method => :put, :remote => true, :class => 'btn btn-primary btn-large' %> - <% end %> +
    + <%= render :partial => 'span2' %>
    -
    @@ -121,7 +60,6 @@
    - <%= render :partial => 'calendar' %>
    From 7a54a99251a3b0f24bf1e21f6db932ccce573ab6 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 23:28:40 -0400 Subject: [PATCH 14/26] spacing is solid --- app/assets/javascripts/calendar.js | 5 +++-- app/assets/stylesheets/equipment_models/_show.css.scss | 2 +- app/views/equipment_models/_calendar.html.erb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 7a4bb66f1..13a2539b4 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -10,14 +10,15 @@ function dateToRubyString(date) { function dateToHeading(date) { var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun']; var day = days[date.getUTCDay()]; - return date.getUTCDate().toString() + " - " + day; + return ' ' + day; }; function renderCalendar(reservations, week_start, max) { //set initial values and date ids var date = new Date(week_start.getTime()); $('.calendar_cell').each(function() { - $(this).children('.head').children()[0].innerHTML = dateToHeading(date); + $(this).children('.head').children()[0].innerHTML = date.getUTCDate().toString(); + $(this).children('.head').children()[1].innerHTML = dateToHeading(date); $(this).children('.num').children()[0].innerHTML = max.toString(); $(this).attr('id',dateToRubyString(date)); date.setDate(date.getDate()+1); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 688476478..be98a5935 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -22,7 +22,7 @@ $border-att: 1px solid darken($bodyBackground, 20%); } .today { - border: 2px solid darken($bodyBackground, 30%); + border: 1px solid darken($bodyBackground, 30%); } .calendar_cell:hover{ diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 92ce1b3ca..1af022a23 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -7,12 +7,12 @@
    • <% for d in 0...6 %> -
      +

    • <% end %> -
      +

    From 2ed2e66d881f070c1bf3d8e73e9923f08e0985a5 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 23:45:12 -0400 Subject: [PATCH 15/26] minor layout changes --- app/assets/javascripts/calendar.js | 6 +----- app/assets/stylesheets/equipment_models/_show.css.scss | 4 ++-- app/views/equipment_models/_calendar.html.erb | 5 ++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 13a2539b4..319b6c02a 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -25,7 +25,7 @@ function renderCalendar(reservations, week_start, max) { }); var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; - $('.month').children()[0].innerHTML = "Availability: " + months[week_start.getMonth()] + " " + date.getFullYear().toString(); + $('.month').children()[0].innerHTML = months[week_start.getMonth()] + " " + date.getFullYear().toString(); //set cell values based on reservations @@ -54,10 +54,6 @@ function renderCalendar(reservations, week_start, max) { var color = 'rgba(' + red + ',' + green + ',0,0.5)'; $(this).css("background-color",color); - if ($(this).attr('id') == $('#res-data').data('today')) { - $(this).addClass('today'); - } - }); }; diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index be98a5935..8be9db238 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -21,8 +21,8 @@ $border-att: 1px solid darken($bodyBackground, 20%); padding-bottom: 5px; } -.today { - border: 1px solid darken($bodyBackground, 30%); +.month-link { + float: right; } .calendar_cell:hover{ diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 1af022a23..baaa0040d 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,8 +1,8 @@ +

    Availability

    <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date.to_s, max:@max} do %> <% end %> - -

    +

    • @@ -17,7 +17,6 @@
    -
    back a week back 1 day From 4a6021f2644d1ac2f04c811bc67d5140d69d4e8a Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 23:57:13 -0400 Subject: [PATCH 16/26] cleaned up commit --- Gemfile | 1 - Gemfile.lock | 2 -- app/assets/javascripts/calendar.js | 7 +++++++ app/views/equipment_models/_calendar.html.erb | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index f276263aa..a23769dc8 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,6 @@ gem 'rails3-jquery-autocomplete' gem 'select2-rails' gem 'kaminari' gem 'spinjs-rails' -gem "watu_table_builder", :require => "table_builder" #forms / formatting gem 'dynamic_form' diff --git a/Gemfile.lock b/Gemfile.lock index 481f75c1f..f7d23f796 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -298,7 +298,6 @@ GEM uglifier (2.2.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) - watu_table_builder (0.3.0) websocket (1.0.7) whenever (0.8.4) activesupport (>= 2.3.4) @@ -362,6 +361,5 @@ DEPENDENCIES therubyracer thin uglifier - watu_table_builder whenever yajl-ruby diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 319b6c02a..3d488f751 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -96,5 +96,12 @@ $('#reservation-calendar').ready(function() { shiftCalendar(-7); }); + $('#cart_start_date_cart').change(function() { + var reservations = $('#res-data').data('url'); + var week_start = new Date($(this).attr('value')); + + var max = $('#res-data').data('max'); + renderCalendar(reservations,week_start,max); + }); }); diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index baaa0040d..0618625ed 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -5,7 +5,7 @@

      -
    • +
    • <% for d in 0...6 %>

      From 1aafb3067614472b752d88a984c84a5d2733e355 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sat, 21 Jun 2014 23:59:07 -0400 Subject: [PATCH 17/26] clean up commit round 2 --- app/assets/javascripts/calendar.js | 1 + spec/mailers/admin_mailer_spec.rb | 27 - spec/mailers/user_mailer_spec.rb | 6 - test.txt | 1366 ---------------------------- 4 files changed, 1 insertion(+), 1399 deletions(-) delete mode 100644 spec/mailers/admin_mailer_spec.rb delete mode 100644 spec/mailers/user_mailer_spec.rb delete mode 100644 test.txt diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 3d488f751..018669849 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -97,6 +97,7 @@ $('#reservation-calendar').ready(function() { }); $('#cart_start_date_cart').change(function() { + console.log('changed!'); var reservations = $('#res-data').data('url'); var week_start = new Date($(this).attr('value')); diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb deleted file mode 100644 index 7db8af09a..000000000 --- a/spec/mailers/admin_mailer_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe AdminMailer do - - shared_examples_for "admin email" do - it "is only sent to one address" do - expect(mail.to.size).to eq(1) - end - it "is to the admin" do - expect(mail.to.first).to eq(AppConfig.first.admin_email) - end - it "delivers" do - expect { mail.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) - end - end - - describe 'Notes Reservation Notification' do - subject(:res){FactoryGirl.build(:valid_reservation, :notes => "notes")} - subject(:mail) {AdminMailer.notes_reservation_notification(res,res)} - it_behaves_like "admin email" - end - describe 'overdue checked in email' do - # subject(:res){FactoryGirl.build(:valid_reservation)} - # subject(:mail) {AdminMailer.overdue_checked_in_fine_admin(res)} - # it_behaves_like 'admin email' - end -end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb deleted file mode 100644 index bc08b0340..000000000 --- a/spec/mailers/user_mailer_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -describe UserMailer do - - -end diff --git a/test.txt b/test.txt deleted file mode 100644 index 6aba0cca9..000000000 --- a/test.txt +++ /dev/null @@ -1,1366 +0,0 @@ -Run options: include {:focus=>true} - -All examples were filtered out; ignoring {:focus=>true} - -CheckinProcedure - should belong to equipment_model - -Cart - has a working factory - General validations - should require reserver_id to be set - should require start_date to be set - should require due_date to be set - Reservation date changes - .set_due_date - sets new due dates for all items in cart - .set_start_date - does not set a past date as start date - sets new start and due dates for all items in cart - .fix_due_date - sets due date as start_date + 1 if due date precedes start date - does not affect due date when due date does not precede start date - Aliases - .cart_reservations - finds items - .models_with_quantities - gets the correct count of models - .reserver - should return a correct user instance - .duration - should calculate the sum correctly - .set_reserver_id - should flag every CartReservation with passed user_id - .persisted? - should be false - .initialize - has no items - has no reserver - is due tomorrow - starts today - has errors - .empty? - is true when there are no items in cart - is false when there are some items in cart - Item handling - .add_item - adds an item - .remove_item - removes an item from cart - removes a CartReservation from database - removes the right model from cart - -EquipmentObjectsController - GET index - with admin user - should respond with 200 - should render template matcher "index" - should not set the flash - without show deleted - with @equipment_model set - should populate an array of all active model-type equipment objects - without @equipment_model set - should populate an array of all active equipment objects (FAILED - 1) - with show deleted - with @equipment_model set - should populate an array of all model-type equipment objects - without @equipment_model set - should populate an array of all equipment objects (FAILED - 2) - with checkout person user - should respond with 200 - should render template matcher "index" - with non-admin user - should redirect to root - DELETE destroy - with admin user - should remove object from database - - should set the flash - should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 84, created_at: "2014-06-19 20:51:32", updated_at: "2014-06-19 20:51:32", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> - sets @equipment_object to selected object - with non-admin user - should redirect to root - GET edit - with admin user - should respond with 200 - should render template matcher "edit" - sets @equipment_object to selected object - should not set the flash - with non-admin user - should redirect to root - GET new - with admin user - should respond with 200 - sets equipment_model when one is passed through params - assigns a new equipment object to @equipment_object - should not set the flash - should render template matcher "new" - sets equipment_model to nil when no equipment model is specified - with non-admin user - should redirect to root - GET show - with admin user - should respond with 200 - should render template matcher "show" - should set to correct equipment object - should not set the flash - with non-admin user - should redirect to root - PUT update - with admin user - with valid attributes - should set the flash - sets @equipment_object to selected object - should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 106, created_at: "2014-06-19 20:51:35", updated_at: "2014-06-19 20:51:35", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> - updates attributes - without valid attributes - should not set the flash - should not update attributes - should render template matcher "edit" - with non-admin user - should redirect to root - POST create - with admin user - with valid attributes - should save object - should set the flash - should change default serial to nil - should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 115, created_at: "2014-06-19 20:51:36", updated_at: "2014-06-19 20:51:36", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> - without valid attributes - should not set the flash - should render template matcher "new" - should render template matcher "new" - should not save - with non-admin user - should redirect to root - -Reservation - should belong to equipment_model - should require equipment_model to be set - should belong to checkout_handler - should belong to equipment_object - should belong to reserver - should belong to checkin_handler - when valid - should be valid - should respond to #late_fee - passes custom validations - should respond to #max_renewal_length_available - should save (FAILED - 3) - should have a valid reserver - should respond to #fake_reserver_id - can be updated - equipment_model - should not be nil - start_date - should not be nil - due_date - should not be nil - with no user - should have a deleted user - should be valid - when overdue - should be is eligible for renew - status - should == "overdue" - when not checked out - status - should == "reserved" - when missed - status - should == "missed" - when checked in - should not be is eligible for renew - status - should == "returned on time" - with equipment model quantity problems - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 4) - passes other custom validations - when user has overdue reservation - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 5) - passes other custom validations - with equipment object/model matching problems - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 6) - passes other custom validations - when empty - should not be valid - should not save (FAILED - 7) - updates with equipment model (FAILED - 8) - cannot be updated - with category quantity problems - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 9) - passes other custom validations - with past due date - should not be valid - updates with fixed date (FAILED - 10) - fails appropriate validations - cannot be updated - should not save (FAILED - 11) - passes other custom validations - when checked out - should be is eligible for renew - status - should == "checked out" - with duration problems - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 12) - passes other custom validations - with equipment object available problems - passes other custom validations - with blacked out start date - should not be valid - fails appropriate validations - cannot be updated - should not save (FAILED - 13) - passes other custom validations - -Category - validates max_per_user must be non-negative - validates max_renewal_times can be nil - validates sort_order can be nil - validates max_checkout_length must be an integer - validates sort_order must be an integer - validates max_checkout_length can be nil - validates renewal_days_before_due must be an integer - validates max_renewal_times must be an integer - validates sort_order must be non-negative - validates renewal_days_before_due can be nil - validates max_renewal_length must be an integer - validates max_renewal_times must be non-negative - validates max_per_user can be nil - should have many equipment_models - validates max_per_user must be an integer - validates renewal_days_before_due must be non-negative - validates max_checkout_length must be non-negative - should require name to be set - validates max_renewal_length must be non-negative - should require case sensitive unique value for name - validates max_renewal_length can be nil - .active - Should return all active categories - Should not return inactive categories - .catalog_search - Should return names matching all of the query words - Should not return any categories without every query word in the name - #maximum_renewal_days_before_due - Should return maximum_renewal_days_before_due if defined - Default to unrestricted if not defined - #maximum_renewal_length - Should return maximum_renewal_length if defined - Default to 0 if not defined - #maximum_per_user - Should return maximum_per_user if defined - Should return 'unrestricted' if not defined - #maximum_checkout_length - Should return maximum_checkout_length if defined - Default to unrestricted if not defined - #maximum_renewal_times - Should return maximum_renewal_times if defined - Default to unrestricted if not defined - -Requirement - Validations - has a working factory (FAILED - 14) - should have and belong to many users - should require contact_info to be set - should require description to be set - should require contact_name to be set - should have and belong to many equipment_models - #list_requirement_admins - should return a list of admins and contact info if no requirements have been met. (FAILED - 15) - should return a list of met requirements, followed by unmet requirements if they exists (FAILED - 16) - -AppConfig - has a working factory - has an attachment that is of the favicon format - shouldn't have an invalid e-mail - does not accept too long a site title - does not accept empty site title - should have a valid and present e-mail - -RequirementsController - GET index - is admin - example at ./spec/controllers/requirements_controller_spec.rb:19 (FAILED - 17) - example at ./spec/controllers/requirements_controller_spec.rb:20 (FAILED - 18) - should populate an array of all requirements (FAILED - 19) - should not set the flash - not an admin - should redirect to root url if not an admin - DELETE destroy - is admin - assigns the selected requirement to @requirement - removes @requirement from the database - should redirect to the requirements index page - not admin - should redirect to root url if not an admin - PUT update - is admin - with valid attributes - should set @requirement to the correct requirement - should update the attributes of @requirement - should set the flash - should redirect to # - with invalid attributes - should not update the attributes of @requirement - should render template matcher "edit" - should not set the flash - not admin - should redirect to root url if not an admin - GET new - is admin - should respond with 200 - should render template matcher "new" - assigns a new requirement to @requirement - should not set the flash - not an admin - should redirect to root url if not an admin - GET show - is an admin - should respond with 200 - should render template matcher "show" - should set @requirement to the selected requirement - should not set the flash - not an admin - should redirect to root url if not an admin - POST create - is admin - with valid attributes - saves a new requirement - should redirect to # - should set the flash - with invalid attributes - fails to save a new requirment - should not set the flash - should render template matcher "new" - not admin - should redirect to root url if not an admin - GET edit - is admin - should set @requirement to the selected requirement - should respond with 200 - should not set the flash - should render template matcher "edit" - not admin - should redirect to root url if not an admin - -Blackout - validations and associations - should require notice to be set - validates a set_id if it is a recurring blackout (PENDING: Not yet implemented) - should require equipment_model_id to be set - should require end_date to be set - should require start_date to be set - should belong to equipment_model - should require blackout_type to be set - .blackouts_on_date - Should return the blackout blocking a passed date if exists - Should return nil if the date is not blacked out - Should return an array if multiple blackouts cover date - .hard_blackout_exists_on_date - Should return true if there is a hard blackout on the given date - Should return false if there is a soft blackout or no blackout on the given date - -AdminMailer - Notes Reservation Notification - behaves like admin email - is only sent to one address - is to the admin - delivers - -ContactController - GET new - should assign @message to a new message - should respond with 200 - should not set the flash - should render template matcher "new" - POST create - with valid attributes - sends a message (FAILED - 20) - should redirect to "/" - should set the flash - with invalid attributes - should render template matcher "new" - should set the flash - should not send a message - -EquipmentModelsController - GET index - with admin user - should respond with 200 - should render template matcher "index" - should not set the flash - without show deleted - with @category set - should populate an array of of active category-type equipment models - without @category set - should populate an array of all active equipment models (FAILED - 21) - with show deleted - with @category set - should populate an array of category-type equipment models - without @category set - should populate an array of all equipment models (FAILED - 22) - with non-admin user - should function normally - should respond with 200 - should render template matcher "index" - DELETE destroy - with admin user - should remove model from database - - sets @equipment_object to selected model - should set the flash - should redirect to "http://test.host/equipment_models" - with non-admin user - DELETE destroy should redirect to root - POST create - with admin user - with valid attributes - should save model - should set the flash - should redirect to #, replacement_fee: #, max_per_user: 10, active: true, category_id: 279, created_at: "2014-06-19 20:51:57", updated_at: "2014-06-19 20:51:57", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10> - without valid attributes - should set the flash - should render template matcher "new" - should render template matcher "new" - should not save - with non-admin user - should redirect to root - GET new - with admin user - should respond with 200 - sets category when one is passed through params - assigns a new equipment model to @equipment_model - should not set the flash - should render template matcher "new" - sets equipment_model to nil when no category is specified - with non-admin user - should redirect to root - GET show - with admin user - should respond with 200 - should limit @associated_equipment_models to maximum 6 - should set to correct equipment model - should not set the flash - should render template matcher "show" - should set @associated_equipment_models - with non-admin user - should funciton normally - should respond with 200 - should render template matcher "show" - PUT update - with admin user - calls delete_files (PENDING: Not yet implemented) - with valid attributes - example at ./spec/controllers/equipment_models_controller_spec.rb:215 (FAILED - 23) - sets @equipment_model to selected model (FAILED - 24) - example at ./spec/controllers/equipment_models_controller_spec.rb:223 (FAILED - 25) - updates attributes (FAILED - 26) - without valid attributes - should not set the flash - should not update attributes - should render template matcher "edit" - with non-admin user - should redirect to root - GET edit - with admin user - should respond with 200 - should render template matcher "edit" - sets @equipment_model to selected model - should not set the flash - with non-admin user - should redirect to root - -CheckoutProcedure - should belong to equipment_model - -TestController - app_setup_check - user and appconfig in the db - should respond with 200 - should render template matcher {:text=>"hello world"} - should not set the flash - no app_config - should set the flash - should render template matcher ["layouts/application", "application_setup/index"] - no user in the db - should set the flash - should render template matcher ["layouts/application", "application_setup/index"] - fix_cart_date - changes cart.start_date to today if date is in the past - does not change the start_date if date is in the future - cart - makes a new cart record for session[:cart] if !cart - returns session[:cart] if cart.reserver_id - returns session[:cart] without a reserver_id if !cart.reserver_id && !current_user - sets the session[:cart].reserver_id to current_user.id if !cart.reserver_id && current_user - seen_app_configs - app configs have not been viewed - should set the flash - should respond with 300..399 - should redirect to "/app_configs" - app configs have been viewed - should not set the flash - should respond with 200 - should not redirect to "/app_configs" - first_time_user - current_user exists - should not set the flash - should not redirect - current_user is nil - should set the flash - should redirect to "/users/new" - params[:action] = "terms_of_service" - should not set the flash - should not redirect - require_admin - admin user - does nothing if admin in admin mode (PENDING: Not yet implemented) - not an admin - redirects to root url if not an admin and no parameter passed (PENDING: Not yet implemented) - redirects to new_path if not an admin and new_path passed (PENDING: Not yet implemented) - redirects to new path admin not in admin mode (PENDING: Not yet implemented) - current_user - @current_user already exists - should return the current user - @current_user does not already exist - session[:cas_user] exists - should find the current user based on the session :cas_user - session[:cas_user] does not exist - should return nil - check_if_is_admin - user is an admin - should not set the flash - should not redirect - user is not an admin - should set the flash - should redirect to "where_i_came_from" - load_configs - should set @app_configs to the first AppConfig - -EquipmentObject - validations - has a working factory - should require name to be set - saves an empty string value as nil for deleted_at field - should require equipment_model to be set - .current_reservation - returns nil if the equipment object does not have an associted reservation - returns the reservation object currently holding this equipment_object if there is one that does - .status - returns 'Deactivated' if the object has a value for deleted_at - returns 'available' if the object is active and not currently checked out - returns a description of the reservation that it is currently associated with if it is active and checked out - .active - Should return all active equipment objects - Should not return inactive equipment objects - .available? - returns true if the equipment object is not checked out - returns false if the equipment object is currently checked out - -Message - validations - should require name to be set - should allow email to be set to any of ["example@example.com", "1a@a.edu", "a@2a.net"] - should require body to be set - should require subject to be set - should require email to be set - should not allow email to be set to any of ["abc", "!s@abc.com", "a@!d.com", "a@a.c0m"] - .persisted? - should always return false - -AnnouncementsHelper - add some examples to (or delete) /home/s/Dropbox/code/STC/reservations/spec/helpers/announcements_helper_spec.rb (PENDING: No reason given) - -Announcements - displays active announcements (FAILED - 27) - -CatalogController - GET index - sets @reserver_id to the current cart.reserver_id - should respond with 200 - should not set the flash - should render template matcher "index" - PUT update_user_per_cat_page - should set session[:user_per_cat_page] to session[:user_cat_items_per_page] if exists - should not alter session[:user_per_cat_page] if session[:user_cat_items_per_page] is nil - should render template matcher {:action=>"cat_pagination"} - should redirect to "/" - PUT remove_from_cart - valid equipment_model selected - should call cart.remove_item to remove item from cart - should set flash[:error] to the result of Reservation.validate_set if exists - should render template matcher {:action=>"update_cart"} - should redirect to "/" - invalid equipment_model selected - should redirect to "/" - should set the flash - should add logger error (FAILED - 28) - PUT add_to_cart - valid equipment_model selected - should call cart.add_item to add item to cart - should set flash[:error] to the result of Reservation.validate_set if exists - should render template matcher {:action=>"update_cart"} - should redirect to "/" - invalid equipment_model selected - should redirect to "/" - should set the flash - should add logger error (FAILED - 29) - PUT search - query is blank - should redirect to "/" - query is not blank - should call catalog_search on EquipmentModel and return active equipment models - should call catalog_search on EquipmentObject - should render template matcher {:action=>"search_results"} - should call catalog_search on Category - -CategoriesController - GET index - user is admin - should populate an array of all categories if show deleted is true (FAILED - 30) - should render template matcher "index" - should respond with 200 - should populate an array of active categories if show deleted is nil or false (FAILED - 31) - should not set the flash - user is not admin - should respond with 200 - should populate an array of all categories if show deleted is true (FAILED - 32) - should not set the flash - should render template matcher "index" - should populate an array of active categories if show deleted is nil or false (FAILED - 33) - DELETE destroy - is admin - assigns the selected category to @category - removes @category from the database - should redirect to the categorys index page - not admin - should redirect to root url - GET edit - is admin - should set @category to the selected category - should respond with 200 - should not set the flash - should render template matcher "edit" - not admin - should redirect to root_url - GET new - is admin - should respond with 200 - should render template matcher "new" - assigns a new category to @category - should not set the flash - not admin - should redirect to root_url - GET show - user is admin - should respond with 200 - should render template matcher "show" - should set @category to the selected category - should not set the flash - user is not admin - should respond with 200 - should render template matcher "show" - should set @category to the selected category - should not set the flash - PUT update - is admin - with valid attributes - should set @category to the correct category - should successfully save new attributes to the database - should set the flash - should redirect to # - with invalid attributes - should not update attributes of @category in the database - should render template matcher "edit" - should not set the flash - not admin - should redirect to root url - POST create - is admin - with valid attributes - saves a new category to the database - should redirect to # - should set the flash - with invalid attributes - fails to save a new category - should set the flash - should render template matcher "new" - not admin - should redirect to root url - -AppConfigsController - GET edit - app_config exists already - user is admin - should render template matcher "edit" - should respond with 200 - should assign @app_config variable to the first appconfig in the db - should not set the flash - user is not admin - should redirect to "/" - app_config does not exist yet - should respond with 200 (FAILED - 34) - should set the flash - should render template matcher ["layouts/application", "application_setup/index"] - POST update - app config already exists - user is admin - assigns current configuration to @app_config (FAILED - 35) - With valid parameters - resets TOS status for all users when :reset_tos_for_users is 1 - maintains TOS status for all users when :reset_tos_for_users is not 1 - restores favicon when appropriate (PENDING: Not yet implemented) - user is not admin - should redirect to "/" - app_config does not exist yet - should respond with 200 (FAILED - 36) - should set the flash - should render template matcher ["layouts/application", "application_setup/index"] - -ApplicationController - PUT update_cart - valid parameters - should update cart dates - should not set the flash - invalid parameters - should set the flash - GET markdown_help - should render template matcher "shared/_markdown_help" - PUT deactivate - should assign @objects_class2 to the object and controller specified by params (PENDING: Not yet implemented) - should delete @objects_class2 (PENDING: Not yet implemented) - should redirect to request.referer (PENDING: Not yet implemented) - should set the flash (PENDING: Not yet implemented) - GET logout - should always set @current_user to nil - should log the user out of CAS (PENDING: Not yet implemented) - DELETE empty_cart - destroys cart reservations for the reserver associated with the current cart - sets the session[:cart] variable back to nil - should set the flash - should redirect to "/" - PUT activate - should assign @model_to_activate to the model to be activated (PENDING: Not yet implemented) - should set the flash (PENDING: Not yet implemented) - should revive @model_to_activate (PENDING: Not yet implemented) - should call activatParents on the assigned model (PENDING: Not yet implemented) - should redirect to request.referer (PENDING: Not yet implemented) - GET terms_of_service - should render template matcher "terms_of_service/index" - assigns @app_config.terms_of_service to @tos - -Announcement - has current scope (FAILED - 37) - does not include ids passed in to current (FAILED - 38) - includes current when nil is passed in (FAILED - 39) - -CartReservation - should belong to equipment_model - should belong to reserver - should require reserver to be set - when valid - should be valid - can be updated - should save - should have a valid reserver - passes custom validations - equipment_model - should not be nil - start_date - should not be nil - due_date - should not be nil - when empty - should not be valid - should not save - can be updated with equipment model - cannot be updated - with bad dates - should not be valid - should not save - can be updated with fixed date - cannot be updated - -User - has a working factory - validations and associations - should have many reservations - should not allow email to be set to any of ["abc", "!s@abc.com", "a@!d.com", "a@a.c0m"] - should require first_name to be set - should have and belong to many requirements - should require last_name to be set - should require case sensitive unique value for login - doesn't have to accept ToS if created by an admin - should allow email to be set to any of ["example@example.com", "1a@a.edu", "a@2a.net"] - should not allow nickname to be set to any of ["ab@", "ab1", "ab_c"] - should require affiliation to be set - must accept ToS - should require email to be set - should allow nickname to be set to any of [nil, "", "abc", "Example"] - should require login to be set - .name - should return the nickname and last name joined into one string if nickname is specified - should return the first and last name if user has no nickname specified - .checked_out_models - should return a hash of checked out models and counts - .can_checkout? - should return true if user is a checkout person - should return false if admin in normal mode - should return false if user is normal - should return true if user is an admin in checkoutperson mode - should return true if user is an admin in admin mode - should return false if admin in bannedmode - should return false if user is banned - nickname - should default to empty string - should not allow nil - .active - should return all active users - should not return inactive users - #search_ldap - should return a hash of user attributes if the ldap database has the login associated with user (PENDING: Not yet implemented) - should return nil if the user is not in the ldap database (PENDING: Not yet implemented) - #select_options - should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] (FAILED - 40) - .is_admin? - should return true if user is admin and passed no parameter - not an admin - should return false if user is not an admin and passed no parameter - should return false if user is not admin and passed a parameter - banned view_mode - should return true if passed the parameter matching the view_mode - should return false if passed a parameter not matching the view_mode - checkout view_mode - should return true if passed the parameter matching the view_mode - should return false if passed a parameter not matching the view_mode - admin view_mode - should return true if passed the parameter matching the view_mode - should return false if passed a parameter not matching the view_mode - normal view_mode - should return true if passed the parameter matching the view_mode - should return false if passed a parameter not matching the view_mode - .render_name - should return the nickname, last name, and login id as a string if nickname exists - should return the first name, last name, and login id as a string if no nickname - .equipment_objects - has a working reservation factory - should return all equipment_objects reserved by the user - -EquipmentModel - basic validations - requires an integer value for maximum renewal length - requires a maximum per user value greater than or equal to 1 - should accepts_nested_attributes_for :checkout_procedures - requires an integer value for renewal days before due - allows nil values for maximum per user - allows nil values for maximum renewal times - requires a late fee greater than or equal to 0 - should have and belong to many associated_equipment_models - requires a replacement fee greater than or equal to 0 - should require description to be set - should accepts_nested_attributes_for :checkin_procedures - should have many checkout_procedures - requires a maximum renewal length value greater than or equal to 0 - should have and belong to many requirements - requires an integer value for maximum renewal times - requires a maximum renewal times value greater than or equal to 0 - should require name to be set - has a working factory - allows nil values for renewal days before due - should have many reservations - should have many checkin_procedures - should belong to category - should have many equipment_objects - should require case sensitive unique value for name - requires an integer value for maximum per user - requires a renewal days before due value greater than or equal to 0 - allows nil values for maximum renewal length - requires an associated category - instance methods - .maximum_per_user - should return the max_per_user if specified - should return the associated category's max_per_user if unspecified - methods involving reservations - .num_available - should return the number of objects of that model available over a given date range - should return 0 if no objects of that model are available - .available_count - should take the total # of the model, subtract the number reserved, checked-out, and overdue for the given date and return the result - .number_overdue - should return the number of objects of a given model that are checked out and overdue - .number_reserved_on_date - should return the number of objects of that model reserved on that date but not checked in - .available_object_select_options - should make a string listing the available objects - .maximum_renewal_times - should return the max_renewal_times if specified - should return the associated category's max_renewal_length if unspecified - .maximum_renewal_length - should return the max_renewal_length if specified - should return the associated category's max_renewal_length if unspecified - .model_restricted? - should return false if the user has fulfilled the requirements to use the model - should return false if the model has no requirements - should return true if the user has not fulfilled any of the requirements - should return true if the user has not fulfilled all of the requirements - .maximum_renewal_days_before_due - should return the model's renewal_days_before_due if specified - should return the associated category's renewal_days_before_due if unspecified - class methods - #catalog_search - Should return equipment_models with all of the query words in either name or description - Should not return any equipment_models without every query word in the name or description (FAILED - 41) - association validations - has a working association callback - does not permit association with itself - .not_associated_with_self - creates an error if associated with self - -Pending: - Blackout validations and associations validates a set_id if it is a recurring blackout - # Not yet implemented - # ./spec/models/blackout_spec.rb:13 - EquipmentModelsController PUT update with admin user calls delete_files - # Not yet implemented - # ./spec/controllers/equipment_models_controller_spec.rb:236 - TestController require_admin admin user does nothing if admin in admin mode - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:266 - TestController require_admin not an admin redirects to root url if not an admin and no parameter passed - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:269 - TestController require_admin not an admin redirects to new_path if not an admin and new_path passed - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:270 - TestController require_admin not an admin redirects to new path admin not in admin mode - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:271 - AnnouncementsHelper add some examples to (or delete) /home/s/Dropbox/code/STC/reservations/spec/helpers/announcements_helper_spec.rb - # No reason given - # ./spec/helpers/announcements_helper_spec.rb:14 - AppConfigsController POST update app config already exists user is admin With valid parameters restores favicon when appropriate - # Not yet implemented - # ./spec/controllers/app_configs_controller_spec.rb:87 - ApplicationController PUT deactivate should assign @objects_class2 to the object and controller specified by params - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:378 - ApplicationController PUT deactivate should delete @objects_class2 - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:379 - ApplicationController PUT deactivate should redirect to request.referer - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:381 - ApplicationController PUT deactivate should set the flash - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:380 - ApplicationController GET logout should log the user out of CAS - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:362 - ApplicationController PUT activate should assign @model_to_activate to the model to be activated - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:385 - ApplicationController PUT activate should set the flash - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:388 - ApplicationController PUT activate should revive @model_to_activate - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:387 - ApplicationController PUT activate should call activatParents on the assigned model - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:386 - ApplicationController PUT activate should redirect to request.referer - # Not yet implemented - # ./spec/controllers/application_controller_spec.rb:389 - User#search_ldap should return a hash of user attributes if the ldap database has the login associated with user - # Not yet implemented - # ./spec/models/user_spec.rb:223 - User#search_ldap should return nil if the user is not in the ldap database - # Not yet implemented - # ./spec/models/user_spec.rb:224 - -Failures: - - 1) EquipmentObjectsController GET index with admin user without show deleted without @equipment_model set should populate an array of all active equipment objects - Failure/Error: expect(assigns(:equipment_objects).size).to eq(2) - - expected: 2 - got: 13 - - (compared using ==) - # ./spec/controllers/equipment_objects_controller_spec.rb:38:in `block (6 levels) in ' - - 2) EquipmentObjectsController GET index with admin user with show deleted without @equipment_model set should populate an array of all equipment objects - Failure/Error: expect(assigns(:equipment_objects).size).to eq(3) - - expected: 3 - got: 14 - - (compared using ==) - # ./spec/controllers/equipment_objects_controller_spec.rb:64:in `block (6 levels) in ' - - 3) Reservation when valid should save - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:30:in `block (3 levels) in ' - - 4) Reservation with equipment model quantity problems should not save - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:381:in `block (3 levels) in ' - - 5) Reservation when user has overdue reservation should not save - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:213:in `block (3 levels) in ' - - 6) Reservation with equipment object/model matching problems should not save - Failure/Error: Reservation.all.size.should == 0 - expected: 0 - got: 1 (using ==) - # ./spec/models/reservation_spec.rb:278:in `block (3 levels) in ' - - 7) Reservation when empty should not save - Failure/Error: Reservation.all.size.should == 0 - expected: 0 - got: 1 (using ==) - # ./spec/models/reservation_spec.rb:95:in `block (3 levels) in ' - - 8) Reservation when empty updates with equipment model - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:121:in `block (3 levels) in ' - - 9) Reservation with category quantity problems should not save - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:345:in `block (3 levels) in ' - - 10) Reservation with past due date updates with fixed date - Failure/Error: Reservation.all.size.should == 1 - expected: 1 - got: 2 (using ==) - # ./spec/models/reservation_spec.rb:157:in `block (3 levels) in ' - - 11) Reservation with past due date should not save - Failure/Error: Reservation.all.size.should == 0 - expected: 0 - got: 1 (using ==) - # ./spec/models/reservation_spec.rb:131:in `block (3 levels) in ' - - 12) Reservation with duration problems should not save - Failure/Error: Reservation.all.size.should == 0 - expected: 0 - got: 1 (using ==) - # ./spec/models/reservation_spec.rb:311:in `block (3 levels) in ' - - 13) Reservation with blacked out start date should not save - Failure/Error: Reservation.all.size.should == 0 - expected: 0 - got: 1 (using ==) - # ./spec/models/reservation_spec.rb:167:in `block (3 levels) in ' - - 14) Requirement Validations has a working factory - Failure/Error: @requirement.save.should be_true - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '1' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 1, NULL, '2014-06-19 20:51:48') - # ./spec/models/requirement_spec.rb:9:in `block (3 levels) in ' - - 15) Requirement#list_requirement_admins should return a list of admins and contact info if no requirements have been met. - Failure/Error: @requirement = FactoryGirl.create(:requirement) - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '7' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 7, NULL, '2014-06-19 20:51:48') - # ./spec/models/requirement_spec.rb:21:in `block (3 levels) in ' - - 16) Requirement#list_requirement_admins should return a list of met requirements, followed by unmet requirements if they exists - Failure/Error: @requirement = FactoryGirl.create(:requirement) - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '8' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:48', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 8, NULL, '2014-06-19 20:51:48') - # ./spec/models/requirement_spec.rb:21:in `block (3 levels) in ' - - 17) RequirementsController GET index is admin - Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '9' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 9, NULL, '2014-06-19 20:51:49') - # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' - - 18) RequirementsController GET index is admin - Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '10' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 10, NULL, '2014-06-19 20:51:49') - # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' - - 19) RequirementsController GET index is admin should populate an array of all requirements - Failure/Error: @requirement = FactoryGirl.create(:requirement, contact_name: "Adam Bray") - ActiveRecord::RecordNotUnique: - Mysql2::Error: Duplicate entry '11' for key 'PRIMARY': INSERT INTO `requirements` (`contact_info`, `contact_name`, `created_at`, `deleted_at`, `description`, `equipment_model_id`, `id`, `notes`, `updated_at`) VALUES ('adam.bray@yale.edu', 'Adam Bray', '2014-06-19 20:51:49', NULL, 'You must attend a training session with Adam before using this equipment.', NULL, 11, NULL, '2014-06-19 20:51:49') - # ./spec/controllers/requirements_controller_spec.rb:11:in `block (2 levels) in ' - - 20) ContactController POST create with valid attributes sends a message - Failure/Error: ActionMailer::Base.deliveries.last.subject.should eq('[Reservations Specs] ' + FactoryGirl.build(:message).subject) - - expected: "[Reservations Specs] Message" - got: "[Reservations] Message" - - (compared using ==) - # ./spec/controllers/contact_controller_spec.rb:33:in `block (4 levels) in ' - - 21) EquipmentModelsController GET index with admin user without show deleted without @category set should populate an array of all active equipment models - Failure/Error: expect(assigns(:equipment_models).size).to eq(2) - - expected: 2 - got: 3 - - (compared using ==) - # ./spec/controllers/equipment_models_controller_spec.rb:38:in `block (6 levels) in ' - - 22) EquipmentModelsController GET index with admin user with show deleted without @category set should populate an array of all equipment models - Failure/Error: expect(assigns(:equipment_models).size).to eq(3) - - expected: 3 - got: 4 - - (compared using ==) - # ./spec/controllers/equipment_models_controller_spec.rb:64:in `block (6 levels) in ' - - 23) EquipmentModelsController PUT update with admin user with valid attributes - Failure/Error: before { put :update, id: model, equipment_model: - NoMethodError: - undefined method `each' for nil:NilClass - # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' - # ./app/controllers/equipment_models_controller.rb:71:in `update' - # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' - - 24) EquipmentModelsController PUT update with admin user with valid attributes sets @equipment_model to selected model - Failure/Error: before { put :update, id: model, equipment_model: - NoMethodError: - undefined method `each' for nil:NilClass - # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' - # ./app/controllers/equipment_models_controller.rb:71:in `update' - # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' - - 25) EquipmentModelsController PUT update with admin user with valid attributes - Failure/Error: before { put :update, id: model, equipment_model: - NoMethodError: - undefined method `each' for nil:NilClass - # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' - # ./app/controllers/equipment_models_controller.rb:71:in `update' - # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' - - 26) EquipmentModelsController PUT update with admin user with valid attributes updates attributes - Failure/Error: before { put :update, id: model, equipment_model: - NoMethodError: - undefined method `each' for nil:NilClass - # ./app/controllers/equipment_models_controller.rb:92:in `delete_procedures' - # ./app/controllers/equipment_models_controller.rb:71:in `update' - # ./spec/controllers/equipment_models_controller_spec.rb:213:in `block (5 levels) in ' - - 27) Announcements displays active announcements - Failure/Error: visit '/catalog' - NoMethodError: - undefined method `gsub' for nil:NilClass - # ./app/models/user.rb:105:in `search_ldap' - # ./app/controllers/users_controller.rb:54:in `new' - # ./spec/requests/announcements_spec.rb:7:in `block (2 levels) in ' - - 28) CatalogController PUT remove_from_cart invalid equipment_model selected should add logger error - Failure/Error: Rails.logger.should_receive(:error).with("Attempt to add invalid equipment model #{1}") - (#).error("Attempt to add invalid equipment model 1") - expected: 1 time with arguments: ("Attempt to add invalid equipment model 1") - received: 0 times with arguments: ("Attempt to add invalid equipment model 1") - # ./spec/controllers/catalog_controller_spec.rb:81:in `block (4 levels) in ' - - 29) CatalogController PUT add_to_cart invalid equipment_model selected should add logger error - Failure/Error: Rails.logger.should_receive(:error).with("Attempt to add invalid equipment model #{1}") - (#).error("Attempt to add invalid equipment model 1") - expected: 1 time with arguments: ("Attempt to add invalid equipment model 1") - received: 0 times with arguments: ("Attempt to add invalid equipment model 1") - # ./spec/controllers/catalog_controller_spec.rb:49:in `block (4 levels) in ' - - 30) CategoriesController GET index user is admin should populate an array of all categories if show deleted is true - Failure/Error: expect(assigns(:categories)).to eq([@category, @inactive_category]) - - expected: [#, #] - got: [#, #, #] - - (compared using ==) - - Diff: - @@ -1,3 +1,4 @@ - -[#, - +[#, - + #, - #] - # ./spec/controllers/categories_controller_spec.rb:23:in `block (4 levels) in ' - - 31) CategoriesController GET index user is admin should populate an array of active categories if show deleted is nil or false - Failure/Error: expect(assigns(:categories)).to eq([@category]) - - expected: [#] - got: [#, #] - - (compared using ==) - - Diff: - @@ -1,2 +1,2 @@ - -[#] - +[#, #] - # ./spec/controllers/categories_controller_spec.rb:26:in `block (4 levels) in ' - - 32) CategoriesController GET index user is not admin should populate an array of all categories if show deleted is true - Failure/Error: expect(assigns(:categories)).to eq([@category, @inactive_category]) - - expected: [#, #] - got: [#, #, #] - - (compared using ==) - - Diff: - @@ -1,3 +1,4 @@ - -[#, - +[#, - + #, - #] - # ./spec/controllers/categories_controller_spec.rb:42:in `block (4 levels) in ' - - 33) CategoriesController GET index user is not admin should populate an array of active categories if show deleted is nil or false - Failure/Error: expect(assigns(:categories)).to eq([@category]) - - expected: [#] - got: [#, #] - - (compared using ==) - - Diff: - @@ -1,2 +1,2 @@ - -[#] - +[#, #] - # ./spec/controllers/categories_controller_spec.rb:45:in `block (4 levels) in ' - - 34) AppConfigsController GET edit app_config does not exist yet should respond with 200 - Failure/Error: it { should respond_with(:success) } - Expected response to be a 200, but was 302 - # ./spec/controllers/app_configs_controller_spec.rb:43:in `block (4 levels) in ' - - 35) AppConfigsController POST update app config already exists user is admin assigns current configuration to @app_config - Failure/Error: expect(assigns(:app_config)).to eq(@app_config) - - expected: # - got: # - - (compared using ==) - - Diff: - @@ -1,2 +1,2 @@ - -# - +# - # ./spec/controllers/app_configs_controller_spec.rb:63:in `block (5 levels) in ' - - 36) AppConfigsController POST update app_config does not exist yet should respond with 200 - Failure/Error: it { should respond_with(:success) } - Expected response to be a 200, but was 302 - # ./spec/controllers/app_configs_controller_spec.rb:114:in `block (4 levels) in ' - - 37) Announcement has current scope - Failure/Error: passed = Announcement.create! starts_at: 1.day.ago, ends_at: 1.hour.ago - ActiveRecord::RecordInvalid: - Validation failed: Message can't be blank - # ./spec/models/announcement_spec.rb:6:in `block (2 levels) in ' - - 38) Announcement does not include ids passed in to current - Failure/Error: current1 = Announcement.create! starts_at: 1.hour.ago, ends_at: 1.day.from_now - ActiveRecord::RecordInvalid: - Validation failed: Message can't be blank - # ./spec/models/announcement_spec.rb:12:in `block (2 levels) in ' - - 39) Announcement includes current when nil is passed in - Failure/Error: current = Announcement.create! starts_at: 1.hour.ago, ends_at: 1.day.from_now - ActiveRecord::RecordInvalid: - Validation failed: Message can't be blank - # ./spec/models/announcement_spec.rb:18:in `block (2 levels) in ' - - 40) User#select_options should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] - Failure/Error: User.select_options.should == [["#{@user2.last_name}, #{@user2.first_name}", @user2.id],["#{@user1.last_name}, #{@user1.first_name}", @user1.id]] - expected: [["Greene, Jessica", 487], ["Smith, Joseph", 486]] - got: [["Greene, Jessica", 487], ["Smith, Joseph", 486], ["Spencer, Rafaela", 2], ["test, test", 1]] (using ==) - # ./spec/models/user_spec.rb:231:in `block (3 levels) in ' - - 41) EquipmentModel class methods #catalog_search Should not return any equipment_models without every query word in the name or description - Failure/Error: EquipmentModel.catalog_search("Craft beer sartorial four loko").should == [@another_model] - expected: [#, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] - got: [#, replacement_fee: #, max_per_user: 1, active: true, category_id: 1, created_at: "2014-06-19 20:25:03", updated_at: "2014-06-19 20:25:03", deleted_at: nil, photo_file_name: "epson-powerlite.jpg", photo_content_type: "image/jpeg", photo_file_size: 75765, photo_updated_at: "2014-06-19 20:25:02", documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 35, max_renewal_length: 27, renewal_days_before_due: 3646>, #, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] (using ==) - Diff: - @@ -1,2 +1,3 @@ - -[#, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] - +[#, replacement_fee: #, max_per_user: 1, active: true, category_id: 1, created_at: "2014-06-19 20:25:03", updated_at: "2014-06-19 20:25:03", deleted_at: nil, photo_file_name: "epson-powerlite.jpg", photo_content_type: "image/jpeg", photo_file_size: 75765, photo_updated_at: "2014-06-19 20:25:02", documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 35, max_renewal_length: 27, renewal_days_before_due: 3646>, - + #, replacement_fee: #, max_per_user: 10, active: true, category_id: 489, created_at: "2014-06-19 20:52:47", updated_at: "2014-06-19 20:52:47", deleted_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, documentation_file_name: nil, documentation_content_type: nil, documentation_file_size: nil, documentation_updated_at: nil, max_renewal_times: 10, max_renewal_length: 10, renewal_days_before_due: 10>] - # ./spec/models/equipment_model_spec.rb:172:in `block (4 levels) in ' - -Finished in 1 minute 20.3 seconds -599 examples, 41 failures, 20 pending - -Failed examples: - -rspec ./spec/controllers/equipment_objects_controller_spec.rb:34 # EquipmentObjectsController GET index with admin user without show deleted without @equipment_model set should populate an array of all active equipment objects -rspec ./spec/controllers/equipment_objects_controller_spec.rb:59 # EquipmentObjectsController GET index with admin user with show deleted without @equipment_model set should populate an array of all equipment objects -rspec ./spec/models/reservation_spec.rb:28 # Reservation when valid should save -rspec ./spec/models/reservation_spec.rb:379 # Reservation with equipment model quantity problems should not save -rspec ./spec/models/reservation_spec.rb:211 # Reservation when user has overdue reservation should not save -rspec ./spec/models/reservation_spec.rb:276 # Reservation with equipment object/model matching problems should not save -rspec ./spec/models/reservation_spec.rb:93 # Reservation when empty should not save -rspec ./spec/models/reservation_spec.rb:117 # Reservation when empty updates with equipment model -rspec ./spec/models/reservation_spec.rb:343 # Reservation with category quantity problems should not save -rspec ./spec/models/reservation_spec.rb:153 # Reservation with past due date updates with fixed date -rspec ./spec/models/reservation_spec.rb:129 # Reservation with past due date should not save -rspec ./spec/models/reservation_spec.rb:309 # Reservation with duration problems should not save -rspec ./spec/models/reservation_spec.rb:165 # Reservation with blacked out start date should not save -rspec ./spec/models/requirement_spec.rb:8 # Requirement Validations has a working factory -rspec ./spec/models/requirement_spec.rb:28 # Requirement#list_requirement_admins should return a list of admins and contact info if no requirements have been met. -rspec ./spec/models/requirement_spec.rb:35 # Requirement#list_requirement_admins should return a list of met requirements, followed by unmet requirements if they exists -rspec ./spec/controllers/requirements_controller_spec.rb:19 # RequirementsController GET index is admin -rspec ./spec/controllers/requirements_controller_spec.rb:20 # RequirementsController GET index is admin -rspec ./spec/controllers/requirements_controller_spec.rb:22 # RequirementsController GET index is admin should populate an array of all requirements -rspec ./spec/controllers/contact_controller_spec.rb:32 # ContactController POST create with valid attributes sends a message -rspec ./spec/controllers/equipment_models_controller_spec.rb:34 # EquipmentModelsController GET index with admin user without show deleted without @category set should populate an array of all active equipment models -rspec ./spec/controllers/equipment_models_controller_spec.rb:59 # EquipmentModelsController GET index with admin user with show deleted without @category set should populate an array of all equipment models -rspec ./spec/controllers/equipment_models_controller_spec.rb:215 # EquipmentModelsController PUT update with admin user with valid attributes -rspec ./spec/controllers/equipment_models_controller_spec.rb:216 # EquipmentModelsController PUT update with admin user with valid attributes sets @equipment_model to selected model -rspec ./spec/controllers/equipment_models_controller_spec.rb:223 # EquipmentModelsController PUT update with admin user with valid attributes -rspec ./spec/controllers/equipment_models_controller_spec.rb:219 # EquipmentModelsController PUT update with admin user with valid attributes updates attributes -rspec ./spec/requests/announcements_spec.rb:4 # Announcements displays active announcements -rspec ./spec/controllers/catalog_controller_spec.rb:80 # CatalogController PUT remove_from_cart invalid equipment_model selected should add logger error -rspec ./spec/controllers/catalog_controller_spec.rb:48 # CatalogController PUT add_to_cart invalid equipment_model selected should add logger error -rspec ./spec/controllers/categories_controller_spec.rb:21 # CategoriesController GET index user is admin should populate an array of all categories if show deleted is true -rspec ./spec/controllers/categories_controller_spec.rb:25 # CategoriesController GET index user is admin should populate an array of active categories if show deleted is nil or false -rspec ./spec/controllers/categories_controller_spec.rb:40 # CategoriesController GET index user is not admin should populate an array of all categories if show deleted is true -rspec ./spec/controllers/categories_controller_spec.rb:44 # CategoriesController GET index user is not admin should populate an array of active categories if show deleted is nil or false -rspec ./spec/controllers/app_configs_controller_spec.rb:43 # AppConfigsController GET edit app_config does not exist yet should respond with 200 -rspec ./spec/controllers/app_configs_controller_spec.rb:61 # AppConfigsController POST update app config already exists user is admin assigns current configuration to @app_config -rspec ./spec/controllers/app_configs_controller_spec.rb:114 # AppConfigsController POST update app_config does not exist yet should respond with 200 -rspec ./spec/models/announcement_spec.rb:5 # Announcement has current scope -rspec ./spec/models/announcement_spec.rb:11 # Announcement does not include ids passed in to current -rspec ./spec/models/announcement_spec.rb:17 # Announcement includes current when nil is passed in -rspec ./spec/models/user_spec.rb:228 # User#select_options should return an array of all users ordered by last name, each represented by an array like this: ['first_name last_name', id] -rspec ./spec/models/equipment_model_spec.rb:169 # EquipmentModel class methods #catalog_search Should not return any equipment_models without every query word in the name or description - -Randomized with seed 50675 - From da1cc5ae86e12037fd17e694af15dbb333c37f4c Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Sun, 22 Jun 2014 00:03:01 -0400 Subject: [PATCH 18/26] linked to cart date --- app/assets/javascripts/calendar.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 018669849..319b6c02a 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -96,13 +96,5 @@ $('#reservation-calendar').ready(function() { shiftCalendar(-7); }); - $('#cart_start_date_cart').change(function() { - console.log('changed!'); - var reservations = $('#res-data').data('url'); - var week_start = new Date($(this).attr('value')); - - var max = $('#res-data').data('max'); - renderCalendar(reservations,week_start,max); - }); }); From 4f588995f553f8d405c92896d7563e331edce462 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Mon, 23 Jun 2014 16:36:14 -0400 Subject: [PATCH 19/26] Font awesome icons and dried up JS --- app/assets/javascripts/calendar.js | 17 +------- .../equipment_models/_show.css.scss | 40 +++++++++++++++++-- app/views/equipment_models/_calendar.html.erb | 8 ++-- app/views/equipment_models/calendar.js | 1 - 4 files changed, 42 insertions(+), 24 deletions(-) delete mode 100644 app/views/equipment_models/calendar.js diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 319b6c02a..30354aa47 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -80,21 +80,8 @@ $('#reservation-calendar').ready(function() { //set cart dates to day clicked }); - $('.f_day').click(function() { - shiftCalendar(1); + $('.control').click(function() { + shiftCalendar(parseInt($(this).attr('change'))); }); - $('.b_day').click(function() { - shiftCalendar(-1); - }); - - $('.f_week').click(function() { - shiftCalendar(7); - }); - - $('.b_week').click(function() { - shiftCalendar(-7); - }); - - }); diff --git a/app/assets/stylesheets/equipment_models/_show.css.scss b/app/assets/stylesheets/equipment_models/_show.css.scss index 8be9db238..c1a2d3917 100644 --- a/app/assets/stylesheets/equipment_models/_show.css.scss +++ b/app/assets/stylesheets/equipment_models/_show.css.scss @@ -5,8 +5,14 @@ $border-att: 1px solid darken($bodyBackground, 20%); text-align:center; } +.reservation_calendar { + overflow: hidden; +} + #calendar-ul { - margin: 0px; + margin-left: 0px; + margin-bottom: 3px; + margin-top: 3px; } .calendar_cell { @@ -16,17 +22,18 @@ $border-att: 1px solid darken($bodyBackground, 20%); display: inline-block; vertical-align:top; background-color: rgba(0,255,0,0.5); - opacity: 0.8; + opacity: 0.9; padding-top: 3px; padding-bottom: 5px; } -.month-link { - float: right; +.month { + margin-top:3px; } .calendar_cell:hover{ opacity: 1.0; + cursor: pointer; } .c-left { @@ -37,6 +44,31 @@ $border-att: 1px solid darken($bodyBackground, 20%); float: right; } +.control { + font-size:20px; + margin:3px; + opacity: 0.8; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.control:hover{ + cursor:pointer; + opacity: 1.0; +} + +.control:active{ + color: black; +} + +.lite { + opacity: 0.7; +} + .btn-large { float: right; } diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 0618625ed..051f865d1 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -18,11 +18,11 @@
    - back a week - back 1 day + +
    - forward 1 day - forward 1 week + +
    diff --git a/app/views/equipment_models/calendar.js b/app/views/equipment_models/calendar.js deleted file mode 100644 index 9daeafb98..000000000 --- a/app/views/equipment_models/calendar.js +++ /dev/null @@ -1 +0,0 @@ -test From 3060c9a39d8d7e3c70ea38ed62c438c7ea6808a8 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Mon, 23 Jun 2014 16:44:19 -0400 Subject: [PATCH 20/26] rename partial span2 : --- .../equipment_models/{_span2.html.erb => _add_to_cart.html.erb} | 0 app/views/equipment_models/show.html.erb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename app/views/equipment_models/{_span2.html.erb => _add_to_cart.html.erb} (100%) diff --git a/app/views/equipment_models/_span2.html.erb b/app/views/equipment_models/_add_to_cart.html.erb similarity index 100% rename from app/views/equipment_models/_span2.html.erb rename to app/views/equipment_models/_add_to_cart.html.erb diff --git a/app/views/equipment_models/show.html.erb b/app/views/equipment_models/show.html.erb index d42b96da0..2bb6cbe90 100644 --- a/app/views/equipment_models/show.html.erb +++ b/app/views/equipment_models/show.html.erb @@ -34,7 +34,7 @@
    - <%= render :partial => 'span2' %> + <%= render :partial => 'add_to_cart' %>
    From fb89d174af8fc4b37cc5961bdb75efeabb52423f Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Mon, 23 Jun 2014 17:03:02 -0400 Subject: [PATCH 21/26] add click date -> cart date functionality --- app/assets/javascripts/calendar.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 30354aa47..f13f90733 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -3,14 +3,19 @@ function decCellValue(cell) { obj.innerHTML = parseInt(obj.innerHTML) - 1; }; +function parseDate(dateString){ +//why the fck cant we have normal datestrings + var d = new Date(dateString); + var string = d.toISOString(); + return string.substring(5,7) + "/" + string.substring(8,10) + '/' + string.substring(0,4); +} function dateToRubyString(date) { return date.toISOString().substring(0,10); }; function dateToHeading(date) { var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun']; - var day = days[date.getUTCDay()]; - return ' ' + day; + return ' ' + days[date.getUTCDay()]; }; function renderCalendar(reservations, week_start, max) { @@ -27,7 +32,6 @@ function renderCalendar(reservations, week_start, max) { $('.month').children()[0].innerHTML = months[week_start.getMonth()] + " " + date.getFullYear().toString(); - //set cell values based on reservations for(var d = 0; d < reservations.length; d++) { var end = new Date (reservations[d].end); @@ -67,7 +71,6 @@ function shiftCalendar(offset) { if (week_start < today) { week_start.setTime(today.getTime()); } - renderCalendar(reservations,week_start,max); }; @@ -78,6 +81,7 @@ $('#reservation-calendar').ready(function() { $('.calendar_cell').click(function() { //set cart dates to day clicked + $('#cart_start_date_cart').attr('value', parseDate($(this).attr('id'))).trigger('change'); }); $('.control').click(function() { From 8a32474f1ce8de8108b0068b0885201cb7440877 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Tue, 24 Jun 2014 10:43:41 -0400 Subject: [PATCH 22/26] fix shifting bug --- app/assets/javascripts/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index f13f90733..69e2de895 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -42,7 +42,7 @@ function renderCalendar(reservations, week_start, max) { //for each reservation, decrement availability per day var begin_date = ((week_start > start) ? week_start : start); var end_date = ((week_end < end) ? week_end : end); - for (var date = begin_date; + for (var date = new Date(begin_date.getTime()); date <= end_date; date.setDate(date.getDate()+1)) { decCellValue($('#'+dateToRubyString(date))); From 9db7bc71bfa54d3ee2bb93d27662f81e0cac5cfd Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 27 Jun 2014 15:39:25 -0400 Subject: [PATCH 23/26] added blackout dates --- app/assets/javascripts/calendar.js | 30 ++++++++++++++----- .../equipment_models_controller.rb | 8 ++++- app/models/blackout.rb | 3 +- app/views/equipment_models/_calendar.html.erb | 2 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 69e2de895..8e42e7d0e 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -18,7 +18,7 @@ function dateToHeading(date) { return ' ' + days[date.getUTCDay()]; }; -function renderCalendar(reservations, week_start, max) { +function renderCalendar(reservations, week_start, max, blackouts) { //set initial values and date ids var date = new Date(week_start.getTime()); $('.calendar_cell').each(function() { @@ -52,10 +52,22 @@ function renderCalendar(reservations, week_start, max) { //color cells appropriately $('.calendar_cell').each(function() { - var val = parseInt($(this).children('.num').children()[0].innerHTML); - var red = Math.min(Math.floor(510 - val*510/max),255).toString(); - var green = Math.min(Math.floor(val*510/max),255).toString(); - var color = 'rgba(' + red + ',' + green + ',0,0.5)'; + var blacked = false; + for(var b = 0; b < blackouts.length; b++) { + date = new Date($(this).attr('id')); + if ((new Date(blackouts[b].start) <= date) && (new Date(blackouts[b].end) >= date)) { + blacked = true; + break; + } + } + if (blacked) { + var color = '#999999'; + } else { + var val = parseInt($(this).children('.num').children()[0].innerHTML); + var red = Math.min(Math.floor(510 - val*510/max),255).toString(); + var green = Math.min(Math.floor(val*510/max),255).toString(); + var color = 'rgba(' + red + ',' + green + ',0,0.5)'; + } $(this).css("background-color",color); }); @@ -64,19 +76,23 @@ function renderCalendar(reservations, week_start, max) { function shiftCalendar(offset) { var reservations = $('#res-data').data('url'); + var blackouts = $('#res-data').data('blackouts'); var week_start = new Date($('.calendar_cell').first().attr('id')); var today = new Date($('#res-data').data('today')); + var date_max = new Date($('#res-data').data('dateMax')); var max = $('#res-data').data('max'); week_start.setDate(week_start.getDate() + offset); if (week_start < today) { week_start.setTime(today.getTime()); } - renderCalendar(reservations,week_start,max); + if (week_start > date_max) { + week_start.setTime(date_max.getTime()); + } + renderCalendar(reservations,week_start,max,blackouts); }; $('#reservation-calendar').ready(function() { - shiftCalendar(0); $('.calendar_cell').click(function() { diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 48e6472b0..76d5a4237 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -32,9 +32,15 @@ def show @reservation_data << { start: r.start_date, end: r.due_date} end + @blackouts = [] + Blackout.active.each do |b| + @blackouts << { + start: b.start_date, end: b.end_date} + end @date = Time.current.to_date + @date_max = @date + 1.month - 1.week @max = @equipment_model.equipment_objects.count - + @restricted = @equipment_model.model_restricted?(cart.reserver_id) @blacked_out_start = Blackout.hard_blackout_exists_on_date(cart.start_date) @blacked_out_end = Blackout.hard_blackout_exists_on_date(cart.due_date) diff --git a/app/models/blackout.rb b/app/models/blackout.rb index 92246ef38..ed61fbb74 100644 --- a/app/models/blackout.rb +++ b/app/models/blackout.rb @@ -14,7 +14,8 @@ class Blackout < ActiveRecord::Base validate :validate_end_date_before_start_date # this only matters if a user tries to inject into params because the datepicker # doesn't allow form submission of invalid dates - + + scope :active, where("end_date >= ?", Date.today) def self.blackouts_on_date(date) # Returns the blackout object that blacks out the day if the day is blacked out. Otherwise, returns nil. blackouts = [] Blackout.all.each do |blackout| diff --git a/app/views/equipment_models/_calendar.html.erb b/app/views/equipment_models/_calendar.html.erb index 051f865d1..1adbdfbbf 100644 --- a/app/views/equipment_models/_calendar.html.erb +++ b/app/views/equipment_models/_calendar.html.erb @@ -1,6 +1,6 @@

    Availability

    - <%= content_tag "div", id: "res-data", data:{url:@reservation_data, today:@date.to_s, max:@max} do %> + <%= content_tag "div", id: "res-data", data:{url:@reservation_data, blackouts:@blackouts, today:@date.to_s, max:@max, date_max: @date_max.to_s} do %> <% end %>

    From 40d361dac8b780a14111778b3336ee695111d3aa Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 27 Jun 2014 16:03:18 -0400 Subject: [PATCH 24/26] made it not-break jquery datepicker --- app/assets/javascripts/calendar.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/calendar.js b/app/assets/javascripts/calendar.js index 8e42e7d0e..864e0d44c 100644 --- a/app/assets/javascripts/calendar.js +++ b/app/assets/javascripts/calendar.js @@ -93,6 +93,14 @@ function shiftCalendar(offset) { $('#reservation-calendar').ready(function() { + + //quit if no reservation calendar present + //there's probably a better way to do this? + + if ($('#reservation-calendar').size() == 0) { + return false; + } + shiftCalendar(0); $('.calendar_cell').click(function() { From f8db8525a20cd96156ed60d622f9b0af82d3b193 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Fri, 27 Jun 2014 16:14:59 -0400 Subject: [PATCH 25/26] remove restriction of 'add to cart' button over blackout dates --- app/controllers/equipment_models_controller.rb | 4 ---- app/views/equipment_models/_add_to_cart.html.erb | 14 ++++---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/controllers/equipment_models_controller.rb b/app/controllers/equipment_models_controller.rb index 76d5a4237..0d8295eb9 100644 --- a/app/controllers/equipment_models_controller.rb +++ b/app/controllers/equipment_models_controller.rb @@ -42,10 +42,6 @@ def show @max = @equipment_model.equipment_objects.count @restricted = @equipment_model.model_restricted?(cart.reserver_id) - @blacked_out_start = Blackout.hard_blackout_exists_on_date(cart.start_date) - @blacked_out_end = Blackout.hard_blackout_exists_on_date(cart.due_date) - - #binding.pry end diff --git a/app/views/equipment_models/_add_to_cart.html.erb b/app/views/equipment_models/_add_to_cart.html.erb index a48942ebc..8f487e578 100644 --- a/app/views/equipment_models/_add_to_cart.html.erb +++ b/app/views/equipment_models/_add_to_cart.html.erb @@ -1,8 +1,8 @@ - <% if @restricted || @blacked_out_start || @blacked_out_end %> + <% if @restricted %> <%= link_to "#qualifications_modal", class: 'not-qualified-icon-em', rel: "tooltip", - title: 'Not ' + (@restricted ? "Qualified" : "Available") +" (click for more info)", + title: 'Not Qualified (click for more info)', :"data-toggle" => 'modal' do %> <% end %> @@ -10,17 +10,11 @@ From d648934736b5c9a26cbefb0cb16c013788d48539 Mon Sep 17 00:00:00 2001 From: Sylvan Zheng Date: Wed, 2 Jul 2014 14:20:31 -0400 Subject: [PATCH 26/26] remove em show page progress bar js --- app/assets/javascripts/application.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b85ff644f..ab64a24a3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -220,23 +220,6 @@ if ($(window).width() > 767) { $(".not-qualified-icon").tooltip(); $(".not-qualified-icon-em").tooltip(); - // Equipment Model - show - progress bar - - $('.progress .bar').each(function() { - var me = $(this); - var perc = me.attr("data-percentage"); - var current_perc = 0; - - var progress = setInterval(function() { - if (current_perc>=perc) { - clearInterval(progress); - } else { - current_perc = perc; - me.css('width', (current_perc)+'%'); - } - }, 100); - }); - $('.associated_em_box img').popover({ placement: 'bottom' }); $("#my_reservations .dropdown-menu a").popover({ placement: 'bottom' }); $("#my_equipment .dropdown-menu a").popover({ placement: 'bottom' });