-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6692c20
commit aff5ca7
Showing
9 changed files
with
88 additions
and
2 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 |
---|---|---|
|
@@ -11,3 +11,6 @@ | |
|
||
inherit_gem: | ||
rubocop-shopify: rubocop.yml | ||
AllCops: | ||
Excludes: | ||
- db/schema.rb |
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
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class Company < ApplicationRecord | ||
validates :name, presence: true | ||
validate :valid_url | ||
|
||
def valid_url | ||
return if website.nil? | ||
return if PublicSuffix.valid?(website, default_rule: nil) | ||
|
||
errors.add(:website, :valid_url) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,6 @@ | |
# enabled: "ON" | ||
|
||
en: | ||
hello: "Hello world" | ||
errors: | ||
messages: | ||
valid_url: "must be a valid URL" |
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateCompanies < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table(:companies) do |t| | ||
t.string(:name, null: false) | ||
t.string(:website) | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
pixelhub: | ||
name: "Pixelhub" | ||
website: "http://www.pixelhub.nl" |
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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class CompanyTest < ActiveSupport::TestCase | ||
setup do | ||
@company = companies(:pixelhub) | ||
end | ||
|
||
test "should not save company without name" do | ||
@company.name = nil | ||
assert_not @company.valid? | ||
end | ||
|
||
test "should not save company with invalid website" do | ||
@company.website = "invalid" | ||
assert_not @company.valid? | ||
end | ||
|
||
test "should save company without website" do | ||
@company.website = nil | ||
assert @company.valid? | ||
end | ||
end |