Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Allinson Flex Specs #45

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/allinson_flex/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Profile < ApplicationRecord
# serlializations
serialize :profile
# validations
# validates :name, :profile_version, :responsibility, presence: true
validates :name, :profile_version, :responsibility, presence: true
validates :profile, presence: true
validates :profile_version, uniqueness: true
# callbacks
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/contexts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
factory :allinson_flex_context, class: AllinsonFlex::Context do
name { "flexible_context" }
allinson_flex_profile { FactoryBot.build(:allinson_flex_profile) }
allinson_flex_context { FactoryBot.build(:allinson_flex_context) }
# allinson_flex_context { FactoryBot.build(:allinson_flex_context) }
end

factory :allinson_flex_context_assigned, class: AllinsonFlex::Context do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/allinson_flex/profile_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe AllinsonFlex::ProfileClass, type: :model do
let(:profile_class) { FactoryBot.build(:allinson_flex_profile_class) }
let(:profile_class) { FactoryBot.build(:allinson_flex_class) }

it 'is valid' do
expect(profile_class).to be_valid
Expand Down
2 changes: 1 addition & 1 deletion spec/models/allinson_flex/profile_property_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe AllinsonFlex::ProfileProperty, type: :model do
let(:profile_property) { FactoryBot.build(:profile_property) }
let(:profile_property) { FactoryBot.build(:allinson_flex_property) }

it 'is valid' do
expect(profile_property).to be_valid
Expand Down
3 changes: 1 addition & 2 deletions spec/models/allinson_flex/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
describe 'methods' do
before do
profile.add_date_modified
profile.add_profile_data
end

it '#available_classes returns an array of Classes' do
Expand All @@ -36,7 +35,7 @@
end
it '#profile is set' do
expect(profile.profile).to be_present
expect(profile.profile).match('Indiana University')
expect(profile.name).to eq('Indiana University')
end
it '#available_text_names returns an array of values' do
expect(profile.available_text_names).to eq(
Expand Down
4 changes: 2 additions & 2 deletions spec/models/allinson_flex/profile_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe AllinsonFlex::ProfileText, type: :model do
let(:profile_text) { FactoryBot.build(:allinson_flex_profile_text) }
let(:profile_text) { FactoryBot.build(:allinson_flex_text) }

it 'is valid' do
expect(profile_text).to be_valid
Expand All @@ -13,6 +13,6 @@
it { is_expected.to validate_presence_of(:value) }
end
describe 'associations' do
it { is_expected.to belong_to(:textable).optional }
it { is_expected.to belong_to(:textable) }
end
end
12 changes: 7 additions & 5 deletions spec/services/allinson_flex/dynamic_schema_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
work_class_name: 'Image'
)
end
let(:allinson_flex_context) { build(:allinson_flex_context_assigned) }
let(:default_allinson_flex_context) { build(:allinson_flex_context_default) }
let(:dynamic_schema) { build(:dynamic_schema) }
let(:default_dynamic_schema) { build(:dynamic_schema_default) }

let(:allinson_flex_context) { FactoryBot.build(:allinson_flex_context_assigned) }
let(:default_allinson_flex_context) { FactoryBot.build(:allinson_flex_context_default) }
let(:dynamic_schema) { FactoryBot.build(:dynamic_schema) }
let(:default_dynamic_schema) { FactoryBot.build(:dynamic_schema_default) }


before do
allow(AdminSet).to receive_message_chain(:find, :metadata_context).and_return(allinson_flex_context)
Expand All @@ -22,7 +24,7 @@

describe '#new' do
context 'admin_set does not have a metadata_context' do
let(:allinson_flex_context) { create(:allinson_flex_context) }
# let(:allinson_flex_context) { create(:allinson_flex_context) }

it 'raises a custom error' do
expect do
Expand Down
4 changes: 2 additions & 2 deletions spec/services/allinson_flex/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require 'spec_helper'

RSpec.describe AllinsonFlex::Importer do
RSpec.describe AllinsonFlex::Importer, focus: true do
describe '#load_profile_from_path' do
let(:profile) { described_class.load_profile_from_path(path: File.join(RSpec.configuration.fixture_path, 'files/yaml_example.yaml')) }
let(:profile) { described_class.load_profile_from_path(path: './spec/fixtures/files/yaml_example.yaml') }

it 'returns valid with a valid path' do
expect(profile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe 'hyrax/my/allinson_flex_profiles/index.html.erb', type: :view do
RSpec.describe 'views/allinson_flex/profiles/index.html.erb', type: :view do
before do
allow(view).to receive(:current_ability).and_return(ability)
allow(view).to receive(:provide).and_yield
Expand All @@ -15,8 +15,8 @@
let(:ability) { instance_double(Ability, allinson_flex_profile_abilities: true) }

it 'the line item displays the work and its actions' do
expect(rendered).to have_selector('h1', text: 'AllinsonFlex Profiles')
expect(rendered).to have_selector('h1', text: 'Allinson Flex Profiles')
expect(rendered).to have_link('Create Profile')
end
end
end
end