diff --git a/.gitignore b/.gitignore index d445b359..a7fcfcbf 100755 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ log/*.log.* .idea .bundle/* .byebug_history +.DS_Store \ No newline at end of file diff --git a/Gemfile b/Gemfile index 7378ba4d..2519b18d 100755 --- a/Gemfile +++ b/Gemfile @@ -40,6 +40,7 @@ group :test do gem 'rspec-rails', '~> 3.5' gem 'factory_girl_rails' gem 'capybara' + gem 'launchy' gem 'poltergeist', '~> 1.12' gem 'rack-test' gem 'test-unit', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index ab5cc89a..442e75ef 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,6 +160,8 @@ GEM json_pure (1.8.3) jstz-rails (1.0.4.1) railties (~> 3.1) + launchy (2.4.3) + addressable (~> 2.3) less (2.6.0) commonjs (~> 0.2.7) less-rails (2.6.0) @@ -359,6 +361,7 @@ DEPENDENCIES jquery-datatables-rails! jquery-rails (= 2.1.4) json + launchy newrelic_rpm paperclip! pg @@ -386,5 +389,8 @@ DEPENDENCIES uglifier (>= 1.0.3) yaml_db +RUBY VERSION + ruby 2.1.5p273 + BUNDLED WITH - 1.13.6 + 1.13.7 diff --git a/config/database.yml.dist b/config/database.yml.dist index afc0267c..7205e8ba 100755 --- a/config/database.yml.dist +++ b/config/database.yml.dist @@ -24,4 +24,4 @@ production: host: localhost pool: 5 timeout: 5000 - + \ No newline at end of file diff --git a/spec/controllers/absences_controller_spec.rb b/spec/controllers/absences_controller_spec.rb index 850114a5..18ca4fbd 100644 --- a/spec/controllers/absences_controller_spec.rb +++ b/spec/controllers/absences_controller_spec.rb @@ -1,7 +1,8 @@ require 'rails_helper' RSpec.describe AbsencesController do - let(:volunteer) { create :volunteer_with_assignment } + let(:volunteer_with_assignment) { create :volunteer_with_assignment } it_behaves_like 'an authenticated indexable resource' + end diff --git a/spec/factories/volunteers.rb b/spec/factories/volunteers.rb index 4955fdaf..3eab95a3 100755 --- a/spec/factories/volunteers.rb +++ b/spec/factories/volunteers.rb @@ -7,6 +7,15 @@ waiver_signed true waiver_signed_at Time.zone.now + factory :volunteer_with_region do + after(:create) do |v| + region = create(:region) + v.regions << region + v.assigned = true + v.save + end + end + factory :volunteer_with_assignment do after(:create) do |v| a = create(:assignment,volunteer:v) @@ -15,7 +24,7 @@ v.save end end - + trait :not_waived do waiver_signed false waiver_signed_at nil diff --git a/spec/features/volunteer_schedule_absence_spec.rb b/spec/features/volunteer_schedule_absence_spec.rb new file mode 100644 index 00000000..e9154598 --- /dev/null +++ b/spec/features/volunteer_schedule_absence_spec.rb @@ -0,0 +1,55 @@ +require 'rails_helper' + +RSpec.describe 'Scheduling an Absence' do + + # let(:admin) { create :volunteer_with_assignment, admin: true } + let(:today) { Time.zone.today } + let(:in_two_days) { Time.zone.today + 2 } + let(:in_four_days) { Time.zone.today + 4 } + let(:volunteer_with_assignment) { create :volunteer_with_assignment } + + let!(:chain_too_soon) { create(:schedule_chain, day_of_week: in_two_days.wday, detailed_date: today) } + let!(:schedule_volunteer_too_soon) { create(:schedule_volunteer, schedule_chain: chain_too_soon, volunteer: volunteer_with_assignment) } + let!(:recipient_too_soon) { create(:recipient_schedule, schedule_chain: chain_too_soon, position: 1) } + let!(:donor_too_soon) { create(:donation_schedule, schedule_chain: chain_too_soon, position: 2) } + let!(:log_too_soon) { create(:log, when: in_two_days, schedule_chain: chain_too_soon) } + + let!(:chain_ok) { create(:schedule_chain, day_of_week: in_four_days.wday, detailed_date: today) } + let!(:schedule_volunteer_ok) { create(:schedule_volunteer, schedule_chain: chain_ok, volunteer: volunteer_with_assignment) } + let!(:recipient_ok) { create(:recipient_schedule, schedule_chain: chain_ok, position: 1) } + let!(:donor_ok) { create(:donation_schedule, schedule_chain: chain_ok, position: 2) } + let!(:log_ok) { create(:log, when: in_four_days, schedule_chain: chain_ok) } + + let!(:filter_start_day) { (Time.zone.today).strftime('%e') } + let!(:filter_start_month) { (Time.zone.today).strftime('%B') } + let!(:filter_start_year) { (Time.zone.today).strftime('%Y') } + + let!(:filter_end_day) { (Time.zone.today + 30).strftime('%e') } + let!(:filter_end_month) { (Time.zone.today + 30).strftime('%B') } + let!(:filter_end_year) { (Time.zone.today + 30).strftime('%Y') } + + context 'non-admin user' do + context 'WITH assignment' do + it 'can schedule' do + login volunteer_with_assignment + + visit new_absence_path + + select filter_end_month, from: 'absence[stop_date(2i)]' + select filter_end_day, from: 'absence[stop_date(3i)]' + select filter_end_year, from: 'absence[stop_date(1i)]' + + + click_on 'Save changes' + + binding.pry +save_and_open_page + + expect(current_path).to eq(absences_path) + within('.alert') do + expect(page).to have_content('No shifts of yours was found in that timeframe') + end + end + end + end +end