Skip to content

Commit

Permalink
tests for fieldable concern
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldogsbody committed Jul 4, 2022
1 parent 67e0721 commit e2331f2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/concerns/fieldable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require "rails_helper"

describe "Dois", type: :controller do
subject { DataciteDoisController.new }

it "no params" do
params = ActionController::Parameters.new
expect(subject.fields_from_params(params)).to be_nil
expect(subject.fields_hash_from_params(params)).to be_nil
end

it "single value" do
params = ActionController::Parameters.new(fields: { dois: "id" })
expect(subject.fields_from_params(params)).to eq({ dois: ["id"] }.with_indifferent_access)
expect(subject.fields_hash_from_params(params)).to eq({ dois: "id" }.with_indifferent_access)
end

it "multiple values" do
params = ActionController::Parameters.new(fields: { dois: "id,subjects" })
expect(subject.fields_from_params(params)).to eq({ dois: ["id", "subjects"] }.with_indifferent_access)
expect(subject.fields_hash_from_params(params)).to eq({ dois: "id,subjects" }.with_indifferent_access)
end
end

0 comments on commit e2331f2

Please sign in to comment.