abizvn-clients 0.1.0 → 0.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef742b6a267f3681db526125dcd92b3debea320184a198fb6f8a6c8814e039f8
4
- data.tar.gz: ea321c3605284a566af605fa9f63db5949339507216131727c80097117630b0d
3
+ metadata.gz: 34d7b9c57ab919d849a9df3baf5545748e50a76ae84fba272267bf7e35f83d80
4
+ data.tar.gz: aa093abfd3d327fc6aee9224bfd758e626fb11377be8447cae481217797c5e0d
5
5
  SHA512:
6
- metadata.gz: ab72146c6ef395db0bfd93d9388cd49733aee584aabe084e4ae9470ac271ecc693177a80ad60d699d7084bf6f2994fa5e400b5a10f70df9ba6c83280dbecf740
7
- data.tar.gz: b218fedc33357fe0fa882460a8a4c2443ff5d15267267b6fa996a1915f577d7e9c57c7d6f679a1ae3cf59c42928c56df3299160223deafa640b4c743acbb4181
6
+ metadata.gz: d13429a774a5920a95d161b54e63c315f091df0ae55a6cfe96670dbc0b6d6633cf2051ab54615be0584e2228418f72c770b11cc91a55227cdba0d4799e0431f3
7
+ data.tar.gz: 369833ead7ee61d1a34a8af8c49d3d84681d367a2b11398b302ff055d0b72fcd51af79804cc1b1901759e5d8f26e9a5cc4e4f8c24bf5df2c8858cee1499ae020
@@ -8,7 +8,7 @@ module Abizvn
8
8
  has_many :domains, class_name: 'Abizvn::Clients::Domain', foreign_key: :client_id
9
9
  accepts_nested_attributes_for :domains, allow_destroy: true
10
10
 
11
- validates :admin_user_email, presence: true, uniqueness: { case_sensitive: false }, 'valid_email_2/email': true
11
+ validates :admin_user_email, presence: true, 'valid_email_2/email': true
12
12
 
13
13
  validates :name, presence: true, uniqueness: { case_sensitive: false }, length: { maximum: 128 }
14
14
  validates :contact_email, 'valid_email_2/email': true
@@ -5,7 +5,7 @@ module Abizvn
5
5
 
6
6
  self.table_name = 'clients_management_domains'
7
7
 
8
- belongs_to :client, class_name: 'Abizvn::Clients::Client', foreign_key: 'client_id'
8
+ belongs_to :client, class_name: 'Abizvn::Clients::Client', foreign_key: 'client_id', optional: true
9
9
 
10
10
  validates :name, presence: true, uniqueness: { case_sensitive: false }, length: { maximum: 255 }
11
11
  end
@@ -0,0 +1,5 @@
1
+ class UpdateDomainsClientToOptional < ActiveRecord::Migration[7.2]
2
+ def change
3
+ change_column_null :clients_management_domains, :client_id, true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveUniqueForAdminUserEmailOnClients < ActiveRecord::Migration[7.2]
2
+ def change
3
+ remove_index :clients_management_clients, :admin_user_email
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Abizvn
2
2
  module Clients
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :client, class: 'Abizvn::Clients::Client' do
3
+ sequence(:name) { |n| "Test Name #{n}" }
4
+ sequence(:admin_user_email) { |n| "admin#{n}@example.com" }
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :domain, class: 'Abizvn::Clients::Domain' do
3
+ sequence(:name) { |n| "subdomain#{n}.example.com" }
4
+
5
+ association :client, factory: :client
6
+ end
7
+ end
@@ -0,0 +1,58 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Abizvn::Clients::Client, type: :model do
4
+ describe "validations" do
5
+ context 'name validations' do
6
+ before { FactoryBot.create(:client) }
7
+
8
+ it { should validate_presence_of(:name) }
9
+ it { should validate_uniqueness_of(:name).case_insensitive }
10
+ it { should validate_length_of(:name).is_at_most(128) }
11
+ end
12
+
13
+ context 'email fields validations' do
14
+ it { should validate_presence_of(:admin_user_email) }
15
+
16
+ invalid_samples = ['invalid_email', 'invalid@email', 'invalid@email@com'].each do |sample|
17
+ it { should_not allow_value(sample).for(:admin_user_email) }
18
+ it { should_not allow_value(sample).for(:contact_email) }
19
+ end
20
+
21
+ valid_samples = ['valid@example.com', 'valid_123@example.com', 'valid@sub.example.com'].each do |sample|
22
+ it { should allow_value(sample).for(:admin_user_email) }
23
+ it { should allow_value(sample).for(:contact_email) }
24
+ end
25
+ end
26
+
27
+ context 'contact_phone_number' do
28
+ it 'is valid when blank' do
29
+ model = FactoryBot.build(:client, contact_phone_number: nil)
30
+ expect(model).to be_valid
31
+ model = FactoryBot.build(:client, contact_phone_number: "")
32
+ expect(model).to be_valid
33
+ end
34
+
35
+ it 'is valid with a possible phone number' do
36
+ model = FactoryBot.build(:client, contact_phone_number: '+15551234567')
37
+ expect(model).to be_valid
38
+ end
39
+
40
+ it 'is invalid with an impossible phone number' do
41
+ model = FactoryBot.build(:client, contact_phone_number: '123')
42
+ expect(model).not_to be_valid
43
+ expect(model.errors[:contact_phone_number]).to include('is invalid')
44
+ end
45
+
46
+ it 'is invalid with a badly formatted phone number' do
47
+ model = FactoryBot.build(:client, contact_phone_number: 'abcde')
48
+ expect(model).not_to be_valid
49
+ expect(model.errors[:contact_phone_number]).to include('is invalid')
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'associations' do
55
+ it { should have_many(:domains) }
56
+ end
57
+
58
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Abizvn::Clients::Domain, type: :model do
4
+ describe "validations" do
5
+ before { FactoryBot.create(:domain) }
6
+
7
+ it { should validate_presence_of(:name) }
8
+ it { should validate_uniqueness_of(:name).case_insensitive }
9
+ it { should validate_length_of(:name).is_at_most(255) }
10
+ end
11
+
12
+ describe 'associations' do
13
+ it { should belong_to(:client).optional }
14
+ end
15
+ end
@@ -0,0 +1,81 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ require 'spec_helper'
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require_relative '../spec/dummy/config/environment'
5
+ # Prevent database truncation if the environment is production
6
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
7
+ # Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
8
+ # that will avoid rails generators crashing because migrations haven't been run yet
9
+ # return unless Rails.env.test?
10
+ require 'rspec/rails'
11
+ # Add additional requires below this line. Rails is not loaded until this point!
12
+
13
+ # Requires supporting ruby files with custom matchers and macros, etc, in
14
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
15
+ # run as spec files by default. This means that files in spec/support that end
16
+ # in _spec.rb will both be required and run as specs, causing the specs to be
17
+ # run twice. It is recommended that you do not name files matching this glob to
18
+ # end with _spec.rb. You can configure this pattern with the --pattern
19
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
20
+ #
21
+ # The following line is provided for convenience purposes. It has the downside
22
+ # of increasing the boot-up time by auto-requiring all files in the support
23
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
24
+ # require only the support files necessary.
25
+ #
26
+ # Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
27
+
28
+ # Checks for pending migrations and applies them before tests are run.
29
+ # If you are not using ActiveRecord, you can remove these lines.
30
+ begin
31
+ ActiveRecord::Migration.maintain_test_schema!
32
+ rescue ActiveRecord::PendingMigrationError => e
33
+ abort e.to_s.strip
34
+ end
35
+
36
+ # Requires factories for testing
37
+ Dir.glob(File.join(File.dirname(__FILE__), 'factories', '**', '*.rb')).each { |file| require file }
38
+
39
+ RSpec.configure do |config|
40
+ Shoulda::Matchers.configure do |shoulda_config|
41
+ shoulda_config.integrate do |with|
42
+ with.test_framework :rspec
43
+ with.library :rails
44
+ end
45
+ end
46
+
47
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
48
+ config.fixture_paths = [
49
+ Rails.root.join('spec/fixtures')
50
+ ]
51
+
52
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
53
+ # examples within a transaction, remove the following line or assign false
54
+ # instead of true.
55
+ config.use_transactional_fixtures = true
56
+
57
+ # You can uncomment this line to turn off ActiveRecord support entirely.
58
+ # config.use_active_record = false
59
+
60
+ # RSpec Rails uses metadata to mix in different behaviours to your tests,
61
+ # for example enabling you to call `get` and `post` in request specs. e.g.:
62
+ #
63
+ # RSpec.describe UsersController, type: :request do
64
+ # # ...
65
+ # end
66
+ #
67
+ # The different available types are documented in the features, such as in
68
+ # https://rspec.info/features/7-1/rspec-rails
69
+ #
70
+ # You can also this infer these behaviours automatically by location, e.g.
71
+ # /spec/models would pull in the same behaviour as `type: :model` but this
72
+ # behaviour is considered legacy and will be removed in a future version.
73
+ #
74
+ # To enable this behaviour uncomment the line below.
75
+ # config.infer_spec_type_from_file_location!
76
+
77
+ # Filter lines from Rails gems in backtraces.
78
+ config.filter_rails_from_backtrace!
79
+ # arbitrary gems may also be filtered via:
80
+ # config.filter_gems_from_backtrace("gem name")
81
+ end
@@ -0,0 +1,94 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
65
+ config.disable_monkey_patching!
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = "doc"
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abizvn-clients
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
11
+ date: 2025-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -133,10 +133,18 @@ files:
133
133
  - config/routes.rb
134
134
  - db/migrate/20250208042258_adding_clients_table.rb
135
135
  - db/migrate/20250208072035_adding_client_domains_table.rb
136
+ - db/migrate/20250311104419_update_domains_client_to_optional.rb
137
+ - db/migrate/20250311111640_remove_unique_for_admin_user_email_on_clients.rb
136
138
  - lib/abizvn/clients.rb
137
139
  - lib/abizvn/clients/engine.rb
138
140
  - lib/abizvn/clients/version.rb
139
141
  - lib/tasks/abizvn/clients_tasks.rake
142
+ - spec/factories/abizvn/clients/clients.rb
143
+ - spec/factories/abizvn/clients/domains.rb
144
+ - spec/models/abizvn/clients/client_spec.rb
145
+ - spec/models/abizvn/clients/domain_spec.rb
146
+ - spec/rails_helper.rb
147
+ - spec/spec_helper.rb
140
148
  homepage: http://dev.abizvn.com
141
149
  licenses:
142
150
  - MIT