@@ -87,34 +87,57 @@ defmodule Algora.OrganizationsTest do
87
87
assert user . avatar_url == "https://avatars.githubusercontent.com/u/17045339?v=4"
88
88
end
89
89
90
- test "onboard updates existing records when params change" do
91
- assert { :ok , first_result } = Algora.Organizations . onboard_organization ( @ params )
92
-
93
- updated_params =
94
- @ params
95
- |> put_in ( [ :user , :display_name ] , "Updated User" )
96
- |> put_in ( [ :user , :tech_stack ] , [ "Haskell" ] )
97
- |> put_in ( [ :organization , :display_name ] , "Updated Org" )
98
- |> put_in ( [ :organization , :tech_stack ] , [ "Rust" ] )
99
- |> put_in ( [ :organization , :categories ] , [ "nonprofit" ] )
100
- |> put_in ( [ :organization , :hiring ] , false )
101
- |> put_in ( [ :member , :role ] , :mod )
102
-
103
- assert { :ok , second_result } = Algora.Organizations . onboard_organization ( updated_params )
104
-
105
- assert first_result . user . last_context == first_result . org . handle
106
- assert first_result . user . id == second_result . user . id
107
- assert first_result . org . id == second_result . org . id
108
- assert first_result . member . id == second_result . member . id
109
-
110
- assert second_result . user . last_context == second_result . org . handle
111
- assert second_result . user . display_name == "Updated User"
112
- assert second_result . user . tech_stack == [ "Haskell" ]
113
- assert second_result . org . display_name == "Updated Org"
114
- assert second_result . org . tech_stack == [ "Rust" ]
115
- assert second_result . org . categories == [ "nonprofit" ]
116
- assert second_result . org . hiring == false
117
- assert second_result . member . role == :mod
90
+ test "onboard preserves original org details when subsequent teammates join unless autogenerated" do
91
+ assert { :ok , result0 } =
92
+ @ params_crawler
93
+ |> put_in ( [ :organization , :hiring ] , nil )
94
+ |> put_in ( [ :organization , :categories ] , [ ] )
95
+ |> put_in ( [ :organization , :tech_stack ] , [ ] )
96
+ |> put_in ( [ :organization , :og_title ] , "Title 0" )
97
+ |> put_in ( [ :user , :email ] , "[email protected] " )
98
+ |> Algora.Organizations . onboard_organization ( )
99
+
100
+ assert { :ok , result1 } =
101
+ @ params_crawler
102
+ |> put_in ( [ :organization , :hiring ] , false )
103
+ |> put_in ( [ :organization , :categories ] , [ "open_source" ] )
104
+ |> put_in ( [ :organization , :tech_stack ] , [ "Elixir" ] )
105
+ |> put_in ( [ :organization , :og_title ] , "Title 1" )
106
+ |> put_in ( [ :user , :email ] , "[email protected] " )
107
+ |> Algora.Organizations . onboard_organization ( )
108
+
109
+ assert { :ok , result2 } =
110
+ @ params_crawler
111
+ |> put_in ( [ :organization , :hiring ] , true )
112
+ |> put_in ( [ :organization , :categories ] , [ "agency" ] )
113
+ |> put_in ( [ :organization , :tech_stack ] , [ "Phoenix" ] )
114
+ |> put_in ( [ :organization , :og_title ] , "Title 2" )
115
+ |> put_in ( [ :user , :email ] , "[email protected] " )
116
+ |> Algora.Organizations . onboard_organization ( )
117
+
118
+ assert { :ok , result3 } =
119
+ @ params_crawler
120
+ |> put_in ( [ :organization , :hiring ] , false )
121
+ |> put_in ( [ :organization , :categories ] , [ "nonprofit" ] )
122
+ |> put_in ( [ :organization , :tech_stack ] , [ "PostgreSQL" ] )
123
+ |> put_in ( [ :organization , :og_title ] , "Title 3" )
124
+ |> put_in ( [ :user , :email ] , "[email protected] " )
125
+ |> Algora.Organizations . onboard_organization ( )
126
+
127
+ assert Enum . all? ( [ result0 , result1 , result2 , result3 ] , & ( & 1 . org . id == result0 . org . id ) )
128
+ assert Enum . all? ( [ result0 , result1 , result2 , result3 ] , & ( & 1 . org . og_title == "Title 0" ) )
129
+ assert is_nil ( result0 . org . hiring )
130
+ assert result1 . org . hiring == false
131
+ assert result2 . org . hiring == true
132
+ assert result3 . org . hiring == true
133
+ assert result0 . org . categories == [ ]
134
+ assert result1 . org . categories == [ "open_source" ]
135
+ assert result2 . org . categories == [ "open_source" , "agency" ]
136
+ assert result3 . org . categories == [ "open_source" , "agency" , "nonprofit" ]
137
+ assert result0 . org . tech_stack == [ ]
138
+ assert result1 . org . tech_stack == [ "Elixir" ]
139
+ assert result2 . org . tech_stack == [ "Elixir" , "Phoenix" ]
140
+ assert result3 . org . tech_stack == [ "Elixir" , "Phoenix" , "PostgreSQL" ]
118
141
end
119
142
120
143
test "onboard handles user handle collision by generating alternative handles" do
0 commit comments