|
| 1 | +require 'rails_helper' |
| 2 | + |
| 3 | +RSpec.describe Database::DRA::Submitter, type: :model do |
| 4 | + example do |
| 5 | + submission = create(:submission, { |
| 6 | + validation: build(:validation, :valid, { |
| 7 | + user: build(:user, uid: 'alice') |
| 8 | + }) |
| 9 | + }) |
| 10 | + |
| 11 | + user_id = Dway.submitter_db[:login].insert( |
| 12 | + submitter_id: 'alice', |
| 13 | + password: 'password', |
| 14 | + ) |
| 15 | + |
| 16 | + expect(Net::SSH).to receive(:start) |
| 17 | + |
| 18 | + Database::DRA::Submitter.new.submit submission |
| 19 | + |
| 20 | + expect(Dway.drmdb[:submission].count).to eq(1) |
| 21 | + |
| 22 | + dway_submission = Dway.drmdb[:submission].first |
| 23 | + expect(dway_submission).to include(usr_id: user_id, submitter_id: 'alice', serial: 1) |
| 24 | + |
| 25 | + expect(Dway.drmdb[:status_history].count).to eq(1) |
| 26 | + |
| 27 | + status_history = Dway.drmdb[:status_history].first |
| 28 | + expect(status_history).to include(sub_id: dway_submission[:sub_id], status: 100) |
| 29 | + |
| 30 | + expect(Dway.drmdb[:operation_history].count).to eq(1) |
| 31 | + |
| 32 | + operation_history = Dway.drmdb[:operation_history].first |
| 33 | + expect(operation_history).to include(type: 3, summary: 'Status update to new', usr_id: user_id, serial: 1, submitter_id: 'alice') |
| 34 | + |
| 35 | + expect(Dway.drmdb[:ext_entity].count).to eq(1) |
| 36 | + |
| 37 | + ext_entity = Dway.drmdb[:ext_entity].first |
| 38 | + expect(ext_entity).to include(acc_type: 'DRA', ref_name: 'alice-0001', status: 0) |
| 39 | + |
| 40 | + expect(Dway.drmdb[:ext_permit].count).to eq(1) |
| 41 | + |
| 42 | + ext_permit = Dway.drmdb[:ext_permit].first |
| 43 | + expect(ext_permit).to include(ext_id: ext_entity[:ext_id], submitter_id: 'alice') |
| 44 | + end |
| 45 | +end |
0 commit comments