saasable 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 706a317694accede180544529880f60f3e335d01
4
- data.tar.gz: 0c0dbd9d65b4fb663d8d86a8c75db9feb7d73234
3
+ metadata.gz: dad7c49704bb790278241fcb9867b97e72ced7b4
4
+ data.tar.gz: 9163ab17a1a41437c6634ed917c742ae6f297700
5
5
  SHA512:
6
- metadata.gz: 53f9e84236a4a4ec43210c5fd76b2216058085b368d0f79a39e15a9c0fbe25734ae92719d2a1685c40b259ca0225413d05a2248578057a8db141809c519bcc16
7
- data.tar.gz: ac887ff9f4075e3d62d910dabbdbecf969777b365912ff8c6507e62fa23f7b3ce557e01d1f362f9b4d8e6c59fb9dbb2771e4b9356e088e48d0ed4ef2e14c35d8
6
+ metadata.gz: 1926b99934abdcae4e9c5b432f9c98fde1599d0ad223e66aa4a43f78df7b1dea4443ebd60418187108d9bdef48719f8fc8652a4dfd9ba5db7833a443646cc992
7
+ data.tar.gz: 752bf47c660c1d26a3fbfed9a0c681e738fe62dad60a125f4d2bb0ac10d1bd4d7e0f30cd508c130a2d3e76dee102ba8820479e7f7c3332ee25f275a9942ceb80
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.1
1
+ 4.0.2
@@ -2,5 +2,6 @@ module Saasable::Errors
2
2
  class MultipleSaasDocuments < StandardError; end
3
3
  class NoSaasDocuments < StandardError; end
4
4
 
5
+ class MultipleSaasFound < StandardError; end
5
6
  class SaasNotFound < StandardError; end
6
7
  end
@@ -64,13 +64,21 @@ module Saasable::Mongoid::SaasDocument
64
64
  end
65
65
 
66
66
  def find_by_host! a_host
67
- raise Saasable::Errors::NoSaasDocuments, "you need to set one Saasable::SaasDocument" if Saasable::Mongoid::SaasDocument.saas_document.nil?
67
+ if Saasable::Mongoid::SaasDocument.saas_document.nil?
68
+ if Rails.env.production?
69
+ raise Saasable::Errors::NoSaasDocuments, "you need to set one Saasable::SaasDocument"
70
+ else
71
+ return nil
72
+ end
73
+ end
68
74
 
69
- a_saas = Saasable::Mongoid::SaasDocument.saas_document.where(:hosts => a_host).first
70
- if a_saas.nil?
75
+ possible_saas = Saasable::Mongoid::SaasDocument.saas_document.where(:hosts => a_host).to_a
76
+ if possible_saas.empty?
71
77
  raise Saasable::Errors::SaasNotFound, "no #{Saasable::Mongoid::SaasDocument.saas_document.name} found for the host: \"#{a_host}\""
78
+ elsif possible_saas.count > 1
79
+ raise Saasable::Errors::MultipleSaasFound, "more then 1 #{Saasable::Mongoid::SaasDocument.saas_document.name} found for the host: \"#{a_host}\""
72
80
  else
73
- return a_saas
81
+ return possible_saas.first
74
82
  end
75
83
  end
76
84
 
@@ -41,7 +41,7 @@ module Saasable::Mongoid::ScopedDocument
41
41
  end
42
42
 
43
43
  def index_with_saasable(spec, options = nil)
44
- index_without_saasable(spec, options.except(:unique)) # Never create this one with unique since it's only unique in the saas scope.
44
+ index_without_saasable(spec, options.merge({unique: false}))
45
45
  index_without_saasable({saas_id: 1}.merge(spec), options) unless spec.include?(:saas_id)
46
46
  end
47
47
  end
data/saasable.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: saasable 4.0.1 ruby lib
5
+ # stub: saasable 4.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "saasable"
9
- s.version = "4.0.1"
9
+ s.version = "4.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saasable
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Educa2