-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration task for all_fields label
refs #645
- Loading branch information
1 parent
e25d7a9
commit 75b76fa
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class AllFieldsLabelMigration | ||
def self.run | ||
Spotlight::BlacklightConfiguration.all.each do |bc| | ||
bc.search_fields["all_fields"][:label] = "Keyword" | ||
bc.save | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe AllFieldsLabelMigration do | ||
# since code is changed; newly-generated exhibits will get the correct label; | ||
# set them to the old label so we can test. | ||
before do | ||
FactoryBot.create(:exhibit) | ||
FactoryBot.create(:exhibit) | ||
Spotlight::BlacklightConfiguration.all.each do |bc| | ||
bc.search_fields["all_fields"][:label] = "Everything" | ||
bc.save | ||
end | ||
end | ||
|
||
it "changes the label for all_fields search field from Everything to Keyword" do | ||
expect(exhibit_configs.flatten.uniq).to eq ["Everything"] | ||
expect(browse_configs.flatten.uniq).to eq ["Everything"] | ||
described_class.run | ||
expect(exhibit_configs.flatten.uniq).to eq ["Keyword"] | ||
expect(browse_configs.flatten.uniq).to eq ["Keyword"] | ||
end | ||
|
||
def exhibit_configs | ||
Spotlight::Exhibit.all.to_a.map { |e| e.blacklight_config.search_fields["all_fields"][:label] } | ||
end | ||
|
||
def browse_configs | ||
Spotlight::Exhibit.all.to_a.map { |e| e.searches.first.blacklight_config.search_fields["all_fields"][:label] } | ||
end | ||
end |