Skip to content

Commit

Permalink
Merge 9838136 into ae5cddd
Browse files Browse the repository at this point in the history
  • Loading branch information
atz committed Sep 28, 2018
2 parents ae5cddd + 9838136 commit dec0a82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_09_14_014133) do
ActiveRecord::Schema.define(version: 2018_09_28_021042) do

create_table "bundle_contexts", force: :cascade do |t|
t.string "project_name", null: false
t.integer "content_structure", null: false
t.string "bundle_dir", null: false
t.boolean "staging_style_symlink", default: false, null: false
t.integer "content_metadata_creation", null: false
t.integer "user_id", null: false
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id", "project_name"], name: "index_bundle_contexts_on_user_id_and_project_name", unique: true
t.index ["user_id"], name: "index_bundle_contexts_on_user_id"
end

create_table "job_runs", force: :cascade do |t|
t.string "output_location"
t.integer "job_type", null: false
t.integer "bundle_context_id", null: false
t.bigint "bundle_context_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["bundle_context_id"], name: "index_job_runs_on_bundle_context_id"
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/bundle_contexts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
context "POST create" do
context "Valid Parameters" do
let(:output_dir) { "#{Settings.job_output_parent_dir}/#{subject.current_user.sunet_id}/SMPL-multimedia" }
before do
Dir.delete(output_dir) if Dir.exist?(output_dir)
post :create, params: params
end

before { Dir.delete(output_dir) if Dir.exist?(output_dir) }

it 'passes newly created object' do
post :create, params: params
expect(assigns(:bundle_context)).to be_a(BundleContext).and be_persisted
expect(response).to have_http_status(302) # HTTP code for found
expect(response).to redirect_to(job_runs_path(created: 1))
end
it 'has the correct attributes' do
post :create, params: params
bc = assigns(:bundle_context)
expect(bc.project_name).to eq 'SMPL-multimedia'
expect(bc.content_structure).to eq "simple_image"
expect(bc.content_metadata_creation).to eq "default"
expect(bc.bundle_dir).to eq "spec/test_data/smpl_multimedia"
end
it "persists the JobRun" do
Dir.delete(output_dir) if Dir.exist?(output_dir)
it "persists the first JobRun, rejects dups" do
expect { post :create, params: params }.to change(JobRun, :count).by(1)
expect { post :create, params: params }.to raise_error(RuntimeError, /Output directory.*should not already exist/)
Dir.delete(output_dir) if Dir.exist?(output_dir) # even if the directory is missing, cannot reuse user & project_name
expect { post :create, params: params }.to raise_error(ActiveRecord::RecordNotUnique)
end

it "fails if job_type is nil" do
Dir.delete(output_dir) if Dir.exist?(output_dir)
params[:bundle_context][:job_runs_attributes] = { "0" => { job_type: "" } }
expect { post :create, params: params }.not_to change(JobRun, :count)
end
Expand Down

0 comments on commit dec0a82

Please sign in to comment.