ispmail-on-rails 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 26ebc3f4f1d1f46091e87b3643171928c9a9d8b7
4
- data.tar.gz: 502c2f66c1e307e921a6d504e9e6b8ff3ac74ba2
3
+ metadata.gz: 8345a509dd8e2149a30780a79ba40a60061a1668
4
+ data.tar.gz: 88f2515e20acb051baf91fdbfbd8d9b195809c4f
5
5
  SHA512:
6
- metadata.gz: 98008acba0c599aacd6d3099f8b0f2d9b409d231af1e7d32a4b1b23ff57732b2670c248e7e136567a0ec75fc5a555e70f958fa07fb54afd030876d988aa97723
7
- data.tar.gz: 8d3ac999527c9bd1e2325400e240dff30ef6dfefd8eeb1829a9016072abc084368b16a2c4b37e3383f6b4665d56d6f722a17e2c4c9ba0cb8f04064c97e41e3df
6
+ metadata.gz: 4fedb1a4435987c5c2230d7837a9fb37f6dab9384acbeb9c4e6a4e24fee0bb09b69d643e34008106dfbecb6a4a3f7659387966d99d6d5bc57c6d46f939a23bfe
7
+ data.tar.gz: 74fc26fac57282d7f77c30a5270607bfc706bbe9b0ca9482db2a32533836eb998d7fa0b1a7a8cdc05e495415e58c65a2164c91448ff5eeb098b9b22a74724767
@@ -1,6 +1,6 @@
1
1
  class VirtualAlias < ActiveRecord::Base
2
2
  validates :source, presence: true, domain_name: true, email: true
3
- validates :destination, presence: true, alias: true, uniqueness: true
3
+ validates :destination, presence: true, alias: true
4
4
  validates :domain_id, presence: true
5
5
 
6
6
  belongs_to :virtual_domain, foreign_key: :domain_id
@@ -14,7 +14,7 @@ class VirtualAlias < ActiveRecord::Base
14
14
  def complete_emails
15
15
  self.source += "@#{virtual_domain.name}" unless source =~ /@/
16
16
  self.destination += "@#{virtual_domain.name}" unless destination =~ /@/
17
- self.destination = destination.split(/,| /).select {|ds| !ds.empty? }.map(&:strip).join(", ")
17
+ self.destination = destination.split(/,| /).select {|ds| !ds.empty? }.map(&:strip).sort.join(", ")
18
18
  end
19
19
 
20
20
  end
@@ -1,11 +1,13 @@
1
1
  # Validates that a string contains only valid email addresses, separated by comma
2
2
  class AliasValidator < EmailValidator
3
3
  def validate_each(record, attribute, value)
4
- destinations = value.split(",")
5
- unless destinations.map {|destination|
6
- self.class.valid? destination.strip
7
- }.all?
4
+ destinations = value.split(", ")
5
+ unless destinations.map {|destination| self.class.valid?(destination) }.all?
8
6
  record.errors[attribute] << (options[:message] || "is not a valid list of email addresses")
9
7
  end
8
+ existing = VirtualAlias.where(source: record.source, destination: record.destination).count
9
+ if existing != 0
10
+ record.errors[attribute] << (options[:message] || "is already present")
11
+ end
10
12
  end
11
13
  end
@@ -1,7 +1,7 @@
1
1
  module Ispmail
2
2
  module On
3
3
  module Rails
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ispmail-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Runar Ingebrigtsen