espace_membre-ruby 1.1.1 → 1.2

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: fbae60e86ca64c6d034aa0ef062da4acd9e1344e397e0c8bb8b70331fbecf989
4
- data.tar.gz: 0dfb3737dbff3f3eba1710ff55921ad304e665a6af960111845f30e3af59c664
3
+ metadata.gz: 2399b73d995dfdfe2f411e7e65dbb62cef595afdb94626f2b84307e67af46baa
4
+ data.tar.gz: ce273320ba11c6c482e0102089cf9dd482558bfad5def8107ff526c8065530d1
5
5
  SHA512:
6
- metadata.gz: e19498d8dad9a4e2ddac597f1c712c063f438217abcd684ea5a56a2d1bc6238edeecd4bf7bc4c99d3e36c1b8671c0df7a9eb3880cab0a291b4b1aebe3978f9c0
7
- data.tar.gz: dd3cbd06706117fd1ca34583d878ce7f9f8d85811198b656b209268da05a81473a9792e662287b42b545ddd177bdbf8c975192393a32183194fbecda74237c9d
6
+ metadata.gz: 9d81f1e2e53c400e40c74953d195b48da87f05360931e33fc5a991d5d20efe28570c9cb2f814bee43f0339d252356844b6a3b0efd3974af39eb24f89f20b7fcc
7
+ data.tar.gz: 605360aa0096437bafee344e650daab4bfa6c282ad88073b9025a55cdc269a008da8e4333d7c62149ac7d3bfbbbb5b7fc8ce211c105a99bff00db3eeebd75dd6
@@ -2,7 +2,7 @@ module EspaceMembre
2
2
  class Incubator < Record
3
3
  validates :ghid, presence: true
4
4
 
5
- has_many :startups
5
+ has_and_belongs_to_many :startups, join_table: "startups_incubators"
6
6
 
7
7
  def to_s
8
8
  title
@@ -4,6 +4,10 @@ module EspaceMembre
4
4
 
5
5
  belongs_to :incubator
6
6
 
7
+ has_and_belongs_to_many :incubators, join_table: "startups_incubators"
8
+
9
+ after_save :link_principal_incubator
10
+
7
11
  has_many :phases
8
12
 
9
13
  has_and_belongs_to_many :organizations, join_table: "startups_organizations"
@@ -19,6 +23,9 @@ module EspaceMembre
19
23
  class_name: "Phase",
20
24
  inverse_of: :startup
21
25
 
26
+ belongs_to :contact_incubator, class_name: "User", foreign_key: "contact_incubator"
27
+ belongs_to :contact_dinum, class_name: "User", foreign_key: "contact_dinum"
28
+
22
29
  # we must use this tragic hack because a startup can have one or
23
30
  # more phases without an 'end' timestamp, which is wrong and
24
31
  # misleading but that's how the data exists. So instead of
@@ -38,5 +45,17 @@ module EspaceMembre
38
45
  def to_s
39
46
  name
40
47
  end
48
+
49
+ private
50
+
51
+ # The `startups_incubators` join table is the source of truth for the
52
+ # startup/incubator relationship and the database enforces (via a
53
+ # deferred FK) that a startup's principal incubator is present in the
54
+ # join table. Make sure we keep the principal incubator in sync.
55
+ def link_principal_incubator
56
+ return if incubator.nil?
57
+
58
+ incubators << incubator unless incubators.include?(incubator)
59
+ end
41
60
  end
42
61
  end
@@ -1,3 +1,3 @@
1
1
  module EspaceMembre
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2"
3
3
  end
@@ -2,7 +2,7 @@ require 'faker'
2
2
 
3
3
  FactoryBot.define do
4
4
  factory :incubator, class: 'EspaceMembre::Incubator' do
5
- ghid { Faker::Lorem.word.downcase }
5
+ ghid { Faker::Internet.slug }
6
6
  uuid { Faker::Internet.uuid }
7
7
  title { Faker::Lorem.word }
8
8
  end
@@ -2,11 +2,13 @@ require 'faker'
2
2
 
3
3
  FactoryBot.define do
4
4
  factory :startup, class: "EspaceMembre::Startup" do
5
- ghid { Faker::Lorem.word.downcase }
5
+ ghid { Faker::Internet.slug }
6
6
  uuid { Faker::Internet.uuid }
7
7
  name { Faker::Lorem.word }
8
8
  description { Faker::Lorem.paragraph }
9
9
  incubator
10
+ contact_incubator { FactoryBot.create(:user) }
11
+ contact_dinum { FactoryBot.create(:user) }
10
12
 
11
13
  trait :in_investigation do
12
14
  after(:create) do |startup|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espace_membre-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane Maniaci
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 4.0.3
74
+ rubygems_version: 4.0.20
75
75
  specification_version: 4
76
76
  summary: A collection of Ruby code around the EspaceMembre app
77
77
  test_files: []