|
478 | 478 | end |
479 | 479 | end |
480 | 480 |
|
| 481 | + context "csv file with send_reminders header and field missing" do |
| 482 | + let(:file) { fixture_file_upload("partners_missing_send_reminders_field_and_header.csv", "text/csv") } |
| 483 | + subject { post import_csv_partners_path, params: { file: file } } |
| 484 | + |
| 485 | + it "invokes .import_csv" do |
| 486 | + expect(model_class).to respond_to(:import_csv).with(2).arguments |
| 487 | + end |
| 488 | + |
| 489 | + it "redirects to :index" do |
| 490 | + subject |
| 491 | + expect(response).to be_redirect |
| 492 | + end |
| 493 | + |
| 494 | + it "defaults send_reminders to false" do |
| 495 | + subject |
| 496 | + partner = Partner.find_by(name: "Partner 51") |
| 497 | + expect(partner.send_reminders).to be(false) |
| 498 | + end |
| 499 | + end |
| 500 | + |
| 501 | + context "csv file with send_reminders field missing" do |
| 502 | + let(:file) { fixture_file_upload("partners_missing_send_reminders_field.csv", "text/csv") } |
| 503 | + subject { post import_csv_partners_path, params: { file: file } } |
| 504 | + |
| 505 | + it "invokes .import_csv" do |
| 506 | + expect(model_class).to respond_to(:import_csv).with(2).arguments |
| 507 | + end |
| 508 | + |
| 509 | + it "redirects to :index" do |
| 510 | + subject |
| 511 | + expect(response).to be_redirect |
| 512 | + end |
| 513 | + |
| 514 | + it "defaults send_reminders to false" do |
| 515 | + subject |
| 516 | + partner = Partner.find_by(name: "Partner 51") |
| 517 | + expect(partner.send_reminders).to be(false) |
| 518 | + end |
| 519 | + end |
| 520 | + |
481 | 521 | context "csv file with invalid email address" do |
482 | 522 | let(:file) { fixture_file_upload("partners_with_invalid_email.csv", "text/csv") } |
483 | 523 | subject { post import_csv_partners_path, params: { file: file } } |
|
498 | 538 | end |
499 | 539 | end |
500 | 540 |
|
| 541 | + context "csv file with default storage location header and field missing" do |
| 542 | + let(:file) { fixture_file_upload("partners_missing_default_storage_location_field_and_header.csv", "text/csv") } |
| 543 | + subject { post import_csv_partners_path, params: { file: file } } |
| 544 | + |
| 545 | + it "invokes .import_csv" do |
| 546 | + expect(model_class).to respond_to(:import_csv).with(2).arguments |
| 547 | + end |
| 548 | + |
| 549 | + it "redirects to :index" do |
| 550 | + subject |
| 551 | + expect(response).to be_redirect |
| 552 | + end |
| 553 | + |
| 554 | + it "presents a flash notice message" do |
| 555 | + subject |
| 556 | + expect(response).to have_notice "#{model_class.name.underscore.humanize.pluralize} were imported successfully!" |
| 557 | + end |
| 558 | + end |
| 559 | + |
| 560 | + context "csv file with default storage location field missing" do |
| 561 | + let(:file) { fixture_file_upload("partners_missing_default_storage_location_field.csv", "text/csv") } |
| 562 | + subject { post import_csv_partners_path, params: { file: file } } |
| 563 | + |
| 564 | + it "invokes .import_csv" do |
| 565 | + expect(model_class).to respond_to(:import_csv).with(2).arguments |
| 566 | + end |
| 567 | + |
| 568 | + it "redirects to :index" do |
| 569 | + subject |
| 570 | + expect(response).to be_redirect |
| 571 | + end |
| 572 | + |
| 573 | + it "presents a flash notice message" do |
| 574 | + subject |
| 575 | + expect(response).to have_notice "#{model_class.name.underscore.humanize.pluralize} were imported successfully!" |
| 576 | + end |
| 577 | + end |
| 578 | + |
501 | 579 | context "csv file with default storage location, email preferences, quota, and notes" do |
502 | 580 | let(:file) { fixture_file_upload("partners_with_six_fields.csv", "text/csv") } |
503 | 581 | subject { post import_csv_partners_path, params: { file: file } } |
|
530 | 608 |
|
531 | 609 | it "presents a flash error message" do |
532 | 610 | subject |
533 | | - expect(response).to have_error "The following Partners did not import successfully:\nPartner 4: Default storage location The default storage location is not a storage location for this partner's organization" |
| 611 | + expect(response).to have_error "The following Partners did not import successfully:\nPartner 4: default_storage_location The default storage location is not a storage location for this partner's organization" |
534 | 612 | end |
535 | 613 | end |
536 | 614 |
|
|
552 | 630 | expect(response).to have_notice "#{model_class.name.underscore.humanize.pluralize} were imported successfully!" |
553 | 631 | end |
554 | 632 | end |
| 633 | + |
| 634 | + context "csv file with a blank line at the file's bottom" do |
| 635 | + let(:file) { fixture_file_upload("partners_with_final_line_blank.csv", "text/csv") } |
| 636 | + subject { post import_csv_partners_path, params: { file: file } } |
| 637 | + |
| 638 | + it "redirects to :index" do |
| 639 | + subject |
| 640 | + expect(response).to be_redirect |
| 641 | + end |
| 642 | + |
| 643 | + it "presents a flash notice message" do |
| 644 | + subject |
| 645 | + expect(response).to have_notice "#{model_class.name.underscore.humanize.pluralize} were imported successfully!" |
| 646 | + end |
| 647 | + end |
555 | 648 | end |
556 | 649 |
|
557 | 650 | describe "POST #create" do |
|
0 commit comments