Skip to content

Commit f8a7ea6

Browse files
authored
Fix: clone stories excluding status (#349)
* clone stories but leave status * pass what needs to be duplicated * Updated ombu_labs-auth for rails 7.2 * Updated database_cleaner-active_record for Rails 7.2 * Update puma for rails 7.1 and 7.2
1 parent 18085be commit f8a7ea6

File tree

5 files changed

+92
-63
lines changed

5 files changed

+92
-63
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ gem "bootstrap-sass", "3.4.1"
2727
# Use sqlite3 as the database for Active Record
2828
# gem 'sqlite3'
2929
# Use Puma as the app server
30-
gem "puma", "~> 6.4"
30+
gem "puma", "~> 6.5"
3131
# Use SCSS for stylesheets
3232
gem "sass-rails", "~> 5.0"
3333

Gemfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ GEM
214214
newrelic_rpm (9.5.0)
215215
next_rails (1.3.0)
216216
colorize (>= 0.8.1)
217-
nio4r (2.7.0)
217+
nio4r (2.7.4)
218218
nokogiri (1.16.2-arm64-darwin)
219219
racc (~> 1.4)
220220
nokogiri (1.16.2-x86_64-darwin)
@@ -257,7 +257,7 @@ GEM
257257
psych (5.1.0)
258258
stringio
259259
public_suffix (5.0.3)
260-
puma (6.4.2)
260+
puma (6.6.0)
261261
nio4r (~> 2.0)
262262
pundit (2.3.1)
263263
activesupport (>= 3.0.0)
@@ -480,7 +480,7 @@ DEPENDENCIES
480480
next_rails
481481
ombu_labs-auth
482482
pg
483-
puma (~> 6.4)
483+
puma (~> 6.5)
484484
pundit (~> 2.2)
485485
rack-mini-profiler
486486
rails (~> 7.1.0)

Gemfile.next.lock

+69-58
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ GEM
8888
ast (2.4.2)
8989
autoprefixer-rails (10.4.15.0)
9090
execjs (~> 2)
91-
base64 (0.1.1)
92-
bcrypt (3.1.19)
91+
base64 (0.1.2)
92+
bcrypt (3.1.20)
9393
benchmark (0.4.0)
94-
bigdecimal (3.1.4)
94+
bigdecimal (3.1.9)
9595
bindex (0.8.1)
9696
bootstrap-sass (3.4.1)
9797
autoprefixer-rails (>= 5.2.1)
9898
sassc (>= 2.0.0)
9999
bourbon (7.3.0)
100100
thor (~> 1.0)
101-
builder (3.2.4)
101+
builder (3.3.0)
102102
byebug (11.1.3)
103103
capybara (3.39.2)
104104
addressable
@@ -117,15 +117,15 @@ GEM
117117
execjs
118118
coffee-script-source (1.12.2)
119119
colorize (1.1.0)
120-
concurrent-ruby (1.3.4)
121-
connection_pool (2.4.1)
120+
concurrent-ruby (1.3.5)
121+
connection_pool (2.5.2)
122122
crass (1.0.6)
123-
database_cleaner-active_record (2.1.0)
123+
database_cleaner-active_record (2.2.0)
124124
activerecord (>= 5.a)
125125
database_cleaner-core (~> 2.0.0)
126126
database_cleaner-core (2.0.1)
127127
date (3.4.1)
128-
devise (4.8.1)
128+
devise (4.9.4)
129129
bcrypt (~> 3.0)
130130
orm_adapter (~> 0.1)
131131
railties (>= 4.1.0)
@@ -137,9 +137,8 @@ GEM
137137
dotenv-rails (2.8.1)
138138
dotenv (= 2.8.1)
139139
railties (>= 3.2)
140-
drb (2.1.1)
141-
ruby2_keywords
142-
erubi (1.12.0)
140+
drb (2.2.1)
141+
erubi (1.13.1)
143142
execjs (2.9.1)
144143
factory_bot (6.2.1)
145144
activesupport (>= 5.0.0)
@@ -148,19 +147,21 @@ GEM
148147
railties (>= 5.0.0)
149148
faker (3.2.1)
150149
i18n (>= 1.8.11, < 2)
151-
faraday (2.7.11)
152-
base64
153-
faraday-net_http (>= 2.0, < 3.1)
154-
ruby2_keywords (>= 0.0.4)
155-
faraday-net_http (3.0.2)
150+
faraday (2.13.0)
151+
faraday-net_http (>= 2.0, < 3.5)
152+
json
153+
logger
154+
faraday-net_http (3.4.0)
155+
net-http (>= 0.5.0)
156156
ffi (1.16.3)
157157
globalid (1.2.1)
158158
activesupport (>= 6.1)
159159
hashie (5.0.0)
160-
i18n (1.14.1)
160+
i18n (1.14.7)
161161
concurrent-ruby (~> 1.0)
162-
io-console (0.6.0)
163-
irb (1.14.3)
162+
io-console (0.8.0)
163+
irb (1.15.2)
164+
pp (>= 0.6.0)
164165
rdoc (>= 4.0.0)
165166
reline (>= 0.4.2)
166167
jbuilder (2.11.5)
@@ -173,16 +174,17 @@ GEM
173174
jquery-ui-rails (6.0.1)
174175
railties (>= 3.2.16)
175176
json (2.6.3)
176-
jwt (2.7.1)
177+
jwt (2.10.1)
178+
base64
177179
language_server-protocol (3.17.0.3)
178180
launchy (2.5.2)
179181
addressable (~> 2.8)
180182
lint_roller (1.1.0)
181183
listen (3.8.0)
182184
rb-fsevent (~> 0.10, >= 0.10.3)
183185
rb-inotify (~> 0.9, >= 0.9.10)
184-
logger (1.6.4)
185-
loofah (2.21.3)
186+
logger (1.7.0)
187+
loofah (2.24.0)
186188
crass (~> 1.0.2)
187189
nokogiri (>= 1.12.0)
188190
madmin (1.2.8)
@@ -199,26 +201,29 @@ GEM
199201
nokogiri (~> 1)
200202
rake
201203
mini_mime (1.1.5)
202-
mini_portile2 (2.8.4)
203-
minitest (5.20.0)
204-
multi_xml (0.6.0)
205-
net-imap (0.5.5)
204+
mini_portile2 (2.8.8)
205+
minitest (5.25.5)
206+
multi_xml (0.7.1)
207+
bigdecimal (~> 3.1)
208+
net-http (0.6.0)
209+
uri
210+
net-imap (0.5.7)
206211
date
207212
net-protocol
208213
net-pop (0.1.2)
209214
net-protocol
210215
net-protocol (0.2.2)
211216
timeout
212-
net-smtp (0.5.0)
217+
net-smtp (0.5.1)
213218
net-protocol
214219
newrelic_rpm (9.5.0)
215220
next_rails (1.3.0)
216221
colorize (>= 0.8.1)
217-
nio4r (2.5.9)
218-
nokogiri (1.15.4)
222+
nio4r (2.7.4)
223+
nokogiri (1.18.8)
219224
mini_portile2 (~> 2.8.2)
220225
racc (~> 1.4)
221-
nokogiri (1.15.4-x86_64-linux)
226+
nokogiri (1.18.8-x86_64-linux-gnu)
222227
racc (~> 1.4)
223228
oauth2 (2.0.9)
224229
faraday (>= 0.17.3, < 3.0)
@@ -227,13 +232,13 @@ GEM
227232
rack (>= 1.2, < 4)
228233
snaky_hash (~> 2.0)
229234
version_gem (~> 1.1)
230-
ombu_labs-auth (1.0.0)
231-
devise (~> 4.8.1)
235+
ombu_labs-auth (1.1.0)
236+
devise (~> 4.9)
232237
omniauth (~> 2.1.0)
233238
omniauth-github (~> 2.0.0)
234239
omniauth-rails_csrf_protection
235-
rails (>= 6.0)
236-
omniauth (2.1.1)
240+
rails (>= 6.0, < 8.1)
241+
omniauth (2.1.3)
237242
hashie (>= 3.4.6)
238243
rack (>= 2.2.3)
239244
rack-protection
@@ -243,7 +248,7 @@ GEM
243248
omniauth-oauth2 (1.8.0)
244249
oauth2 (>= 1.4, < 3)
245250
omniauth (~> 2.0)
246-
omniauth-rails_csrf_protection (1.0.1)
251+
omniauth-rails_csrf_protection (1.0.2)
247252
actionpack (>= 4.2)
248253
omniauth (~> 2.0)
249254
orm_adapter (0.5.0)
@@ -253,24 +258,29 @@ GEM
253258
ast (~> 2.4.1)
254259
racc
255260
pg (1.5.4)
256-
psych (5.1.0)
261+
pp (0.6.2)
262+
prettyprint
263+
prettyprint (0.2.0)
264+
psych (5.2.3)
265+
date
257266
stringio
258267
public_suffix (5.0.3)
259-
puma (6.4.0)
268+
puma (6.6.0)
260269
nio4r (~> 2.0)
261270
pundit (2.3.1)
262271
activesupport (>= 3.0.0)
263-
racc (1.7.1)
264-
rack (2.2.8)
272+
racc (1.8.1)
273+
rack (2.2.13)
265274
rack-mini-profiler (3.1.1)
266275
rack (>= 1.2.0)
267-
rack-protection (3.1.0)
276+
rack-protection (3.2.0)
277+
base64 (>= 0.1.0)
268278
rack (~> 2.2, >= 2.2.4)
269-
rack-session (1.0.1)
279+
rack-session (1.0.2)
270280
rack (< 3)
271-
rack-test (2.1.0)
281+
rack-test (2.2.0)
272282
rack (>= 1.3)
273-
rackup (1.0.0)
283+
rackup (1.0.1)
274284
rack (< 3)
275285
webrick
276286
rails (7.2.2.1)
@@ -295,9 +305,9 @@ GEM
295305
activesupport (>= 5.0.0)
296306
minitest
297307
nokogiri (>= 1.6)
298-
rails-html-sanitizer (1.6.0)
308+
rails-html-sanitizer (1.6.2)
299309
loofah (~> 2.21)
300-
nokogiri (~> 1.14)
310+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
301311
railties (7.2.2.1)
302312
actionpack (= 7.2.2.1)
303313
activesupport (= 7.2.2.1)
@@ -307,18 +317,18 @@ GEM
307317
thor (~> 1.0, >= 1.2.2)
308318
zeitwerk (~> 2.6)
309319
rainbow (3.1.1)
310-
rake (13.0.6)
320+
rake (13.2.1)
311321
rb-fsevent (0.11.2)
312322
rb-inotify (0.10.1)
313323
ffi (~> 1.0)
314-
rdoc (6.5.0)
324+
rdoc (6.13.1)
315325
psych (>= 4.0.0)
316326
recursive-open-struct (1.1.3)
317327
redcarpet (3.5.1)
318328
regexp_parser (2.8.1)
319-
reline (0.6.0)
329+
reline (0.6.1)
320330
io-console (~> 0.5)
321-
responders (3.1.0)
331+
responders (3.1.1)
322332
actionpack (>= 5.2)
323333
railties (>= 5.2)
324334
rexml (3.2.6)
@@ -357,7 +367,6 @@ GEM
357367
rubocop (>= 1.7.0, < 2.0)
358368
rubocop-ast (>= 0.4.0)
359369
ruby-progressbar (1.13.0)
360-
ruby2_keywords (0.0.5)
361370
rubyzip (2.3.2)
362371
sass (3.7.4)
363372
sass-listen (~> 4.0.0)
@@ -417,20 +426,21 @@ GEM
417426
rubocop-performance (~> 1.19.0)
418427
standardrb (1.0.1)
419428
standard
420-
stringio (3.0.8)
429+
stringio (3.1.7)
421430
terser (1.1.18)
422431
execjs (>= 0.3.0, < 3)
423-
thor (1.2.2)
432+
thor (1.3.2)
424433
tilt (2.3.0)
425-
timeout (0.4.0)
434+
timeout (0.4.3)
426435
turbolinks (5.2.1)
427436
turbolinks-source (~> 5.2)
428437
turbolinks-source (5.2.0)
429438
tzinfo (2.0.6)
430439
concurrent-ruby (~> 1.0)
431440
unicode-display_width (2.5.0)
441+
uri (1.0.3)
432442
useragent (0.16.11)
433-
version_gem (1.1.3)
443+
version_gem (1.1.7)
434444
warden (1.2.9)
435445
rack (>= 2.0.9)
436446
web-console (4.2.1)
@@ -442,14 +452,15 @@ GEM
442452
nokogiri (~> 1.6)
443453
rubyzip (>= 1.3.0)
444454
selenium-webdriver (~> 4.0, < 4.11)
445-
webrick (1.8.1)
455+
webrick (1.9.1)
446456
websocket (1.2.10)
447-
websocket-driver (0.7.6)
457+
websocket-driver (0.7.7)
458+
base64
448459
websocket-extensions (>= 0.1.0)
449460
websocket-extensions (0.1.5)
450461
xpath (3.2.0)
451462
nokogiri (~> 1.8)
452-
zeitwerk (2.6.12)
463+
zeitwerk (2.7.2)
453464

454465
PLATFORMS
455466
ruby
@@ -479,7 +490,7 @@ DEPENDENCIES
479490
next_rails
480491
ombu_labs-auth
481492
pg
482-
puma (~> 6.4)
493+
puma (~> 6.5)
483494
pundit (~> 2.2)
484495
rack-mini-profiler
485496
rails (~> 7.2.0)

app/models/project.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def siblings
7474
end
7575

7676
def clone_stories_into(clone)
77-
stories.each { |story| clone.stories.create(story.dup.attributes) }
77+
stories.each do |story|
78+
attrs = story.dup.attributes.slice("title", "description", "position", "extra_info")
79+
clone.stories.create(attrs)
80+
end
7881
end
7982

8083
def clone_projects_into(clone, only: nil)

spec/models/project_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@
133133
end
134134
end
135135

136+
describe "#cloning behaviour" do
137+
it "clones stories into the new project but does not copy status" do
138+
original_project = FactoryBot.create(:project)
139+
FactoryBot.create(:story, :approved, project: original_project, position: 2)
140+
FactoryBot.create(:story, :rejected, project: original_project, position: 1)
141+
FactoryBot.create(:story, :pending, project: original_project, position: 3)
142+
143+
new_project = FactoryBot.create(:project)
144+
original_project.clone_stories_into(new_project)
145+
new_project.stories.each do |story|
146+
expect(story).to be_pending
147+
end
148+
end
149+
end
150+
136151
def add_sub_project
137152
FactoryBot.create(:project, parent: subject, status: subject.status)
138153
end

0 commit comments

Comments
 (0)