-
Notifications
You must be signed in to change notification settings - Fork 10
Set provider prefix on creation and when editing a provider with no topics #676
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ | |
| </div> | ||
|
|
||
| <div class="card-body"> | ||
| <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"> | ||
| <div class="grid grid-cols-1 md:grid-cols-2 gap-8"> | ||
|
|
||
| <div> | ||
| <label class="input-label">Provider Name</label> | ||
|
|
@@ -97,7 +97,7 @@ | |
| </div> | ||
| </div> | ||
|
|
||
| <div> | ||
| <div class="col-span-full"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before, an overly long
The Now, this has been updated so the
The |
||
| <label class="input-label">File Name Prefix</label> | ||
| <div class="bg-gray-50 p-4 rounded-lg border border-gray-200"> | ||
| <% if @provider.file_name_prefix.present? %> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # == Schema Information | ||
| # | ||
| # Table name: providers | ||
| # Database name: primary | ||
| # | ||
| # id :bigint not null, primary key | ||
| # file_name_prefix :string | ||
| # name :string | ||
| # provider_type :string | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # old_id :integer | ||
| # | ||
| # Indexes | ||
| # | ||
| # index_providers_on_old_id (old_id) UNIQUE | ||
| # | ||
| require "rails_helper" | ||
|
|
||
| RSpec.describe Provider, type: :model do | ||
| let(:provider) { create(:provider) } | ||
| subject { provider } | ||
|
|
||
| describe "validations" do | ||
| it { should validate_presence_of(:provider_type) } | ||
| it { should validate_presence_of(:name) } | ||
| it { should validate_uniqueness_of(:name) } | ||
|
|
||
| describe "#file_name_prefix_may_be_changed" do | ||
| context "when a provider has topics" do | ||
| let!(:topic) { create(:topic, provider: provider) } | ||
|
|
||
| it "returns an error" do | ||
| provider.file_name_prefix = "updated_prefix" | ||
| expect(provider).not_to be_valid | ||
| expect(provider.errors[:file_name_prefix]).to match_array( | ||
| "can't be changed as provider has associated topics and so file names are established" | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| context "when a provider has no topics" do | ||
| it "does not return an error" do | ||
| provider.file_name_prefix = "updated_prefix" | ||
| expect(provider).to be_valid | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe "#has_topics?" do | ||
| context "when a provider has topics" do | ||
| let!(:topic) { create(:topic, provider: provider) } | ||
|
|
||
| it "returns true" do | ||
| expect(provider.has_topics?).to be true | ||
| end | ||
| end | ||
|
|
||
| context "when a provider has no topics" do | ||
| it "returns false" do | ||
| expect(provider.has_topics?).to be false | ||
| end | ||
| end | ||
| end | ||
| end |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the placeholder here to be consistent with the rest of them. I think it is sufficient to have the placeholder give examples, as our help text says what the input should be