@@ -56,24 +56,6 @@ def files_in_repository(git_repo_dir)
56
56
git_repo_dir = repo_dir . join ( result . git_repository . id . to_s )
57
57
expect ( files_in_repository ( git_repo_dir ) ) . to eq [ "hello_world.tf" ]
58
58
end
59
-
60
- # NOTE: Second `.notify` stub below prevents `.sync` from getting fired
61
- it "sets the status to 'new' on create" do
62
- expect ( described_class ) . to receive ( :notify ) . with ( "creation" , manager . id , params ) . and_call_original
63
- expect ( described_class ) . to receive ( :notify ) . with ( "syncing" , manager . id , { } ) . and_return ( true )
64
- result = described_class . create_in_provider ( manager . id , params )
65
-
66
- expect ( result ) . to be_a ( described_class )
67
- expect ( result ) . to have_attributes (
68
- :scm_type => "git" ,
69
- :scm_branch => "master" ,
70
- :status => "new" ,
71
- :last_updated_on => nil ,
72
- :last_update_error => nil
73
- )
74
-
75
- expect ( repos ) . to be_empty
76
- end
77
59
end
78
60
end
79
61
@@ -94,50 +76,6 @@ def files_in_repository(git_repo_dir)
94
76
end
95
77
end
96
78
97
- describe "#verify_ssl" do
98
- it "defaults to OpenSSL::SSL::VERIFY_NONE" do
99
- expect ( subject . verify_ssl ) . to eq ( OpenSSL ::SSL ::VERIFY_NONE )
100
- end
101
-
102
- it "can be updated to OpenSSL::SSL::VERIFY_PEER" do
103
- subject . verify_ssl = OpenSSL ::SSL ::VERIFY_PEER
104
- expect ( subject . verify_ssl ) . to eq ( OpenSSL ::SSL ::VERIFY_PEER )
105
- end
106
-
107
- context "with a created record" do
108
- subject { described_class . last }
109
- let ( :create_params ) { params . merge ( :verify_ssl => OpenSSL ::SSL ::VERIFY_PEER ) }
110
-
111
- before do
112
- allow ( Notification ) . to receive ( :create! )
113
-
114
- described_class . create_in_provider ( manager . id , create_params )
115
- end
116
-
117
- it "pulls from the created record" do
118
- expect ( subject . verify_ssl ) . to eq ( OpenSSL ::SSL ::VERIFY_PEER )
119
- end
120
-
121
- it "pushes updates from the ConfigurationScriptSource to the GitRepository" do
122
- subject . update ( :verify_ssl => OpenSSL ::SSL ::VERIFY_NONE )
123
-
124
- expect ( described_class . last . verify_ssl ) . to eq ( OpenSSL ::SSL ::VERIFY_NONE )
125
- expect ( GitRepository . last . verify_ssl ) . to eq ( OpenSSL ::SSL ::VERIFY_NONE )
126
- end
127
-
128
- it "converts true/false values instead of integers" do
129
- subject . update ( :verify_ssl => false )
130
-
131
- expect ( described_class . last . verify_ssl ) . to ( eq ( OpenSSL ::SSL ::VERIFY_NONE ) )
132
- expect ( GitRepository . last . verify_ssl ) . to ( eq ( OpenSSL ::SSL ::VERIFY_NONE ) )
133
-
134
- subject . update ( :verify_ssl => true )
135
- expect ( described_class . last . verify_ssl ) . to ( eq ( OpenSSL ::SSL ::VERIFY_PEER ) )
136
- expect ( GitRepository . last . verify_ssl ) . to ( eq ( OpenSSL ::SSL ::VERIFY_PEER ) )
137
- end
138
- end
139
- end
140
-
141
79
describe "create_in_provider runs sync" do
142
80
it "finds top level template" do
143
81
record = build_record
@@ -303,16 +241,6 @@ def files_in_repository(git_repo_dir)
303
241
end
304
242
end
305
243
306
- context "with invalid params" do
307
- it "does not create a record and does not call git" do
308
- record = build_record
309
- update_params [ :scm_type ] = 'svn' # oh dear god...
310
-
311
- expect ( AwesomeSpawn ) . to receive ( :run! ) . never
312
- expect { record . update_in_provider update_params } . to raise_error ( ActiveRecord ::RecordInvalid )
313
- end
314
- end
315
-
316
244
context "when there is a network error fetching the repo" do
317
245
before do
318
246
record = build_record
@@ -372,21 +300,6 @@ def files_in_repository(git_repo_dir)
372
300
end
373
301
end
374
302
375
- describe "#delete_in_provider" do
376
- it "deletes the record and removes the git dir" do
377
- record = build_record
378
- git_repo_dir = repo_dir . join ( record . git_repository . id . to_s )
379
- record . delete_in_provider
380
-
381
- # Run most recent queue item (`GitRepository#broadcast_repo_dir_delete`)
382
- MiqQueue . get . deliver
383
-
384
- expect ( record ) . to ( be_deleted )
385
-
386
- expect ( git_repo_dir ) . to_not ( exist )
387
- end
388
- end
389
-
390
303
describe "#delete_in_provider_queue" do
391
304
it "creates a task and queue item" do
392
305
pending "We need to set the embedded_terraform role"
@@ -413,74 +326,4 @@ def build_record
413
326
described_class . create_in_provider manager . id , params
414
327
end
415
328
end
416
-
417
- describe "git_repository interaction" do
418
- let ( :auth ) { FactoryBot . create ( :embedded_terraform_scm_credential ) }
419
- let ( :configuration_script_source ) do
420
- described_class . create! (
421
- :name => "foo" ,
422
- :scm_url => "https://example.com/foo.git" ,
423
- :authentication => auth
424
- )
425
- end
426
-
427
- it "on .create" do
428
- configuration_script_source
429
-
430
- git_repository = GitRepository . first
431
- expect ( git_repository . name ) . to eq "foo"
432
- expect ( git_repository . url ) . to eq "https://example.com/foo.git"
433
- expect ( git_repository . authentication ) . to eq auth
434
-
435
- expect { configuration_script_source . git_repository } . to_not make_database_queries
436
- expect ( configuration_script_source . git_repository_id ) . to eq git_repository . id
437
- end
438
-
439
- it "on .new" do
440
- configuration_script_source = described_class . new (
441
- :name => "foo" ,
442
- :scm_url => "https://example.com/foo.git" ,
443
- :authentication => auth
444
- )
445
-
446
- expect ( GitRepository . count ) . to eq 0
447
-
448
- attached_git_repository = configuration_script_source . git_repository
449
-
450
- git_repository = GitRepository . first
451
- expect ( git_repository ) . to eq attached_git_repository
452
- expect ( git_repository . name ) . to eq "foo"
453
- expect ( git_repository . url ) . to eq "https://example.com/foo.git"
454
- expect ( git_repository . authentication ) . to eq auth
455
-
456
- expect { configuration_script_source . git_repository } . to_not make_database_queries
457
- expect ( configuration_script_source . git_repository_id ) . to eq git_repository . id
458
- end
459
-
460
- it "errors when scm_url is invalid" do
461
- expect { configuration_script_source . update! ( :scm_url => "invalid url" ) } . to raise_error ( ActiveRecord ::RecordInvalid )
462
- end
463
-
464
- it "syncs attributes down" do
465
- configuration_script_source . name = "bar"
466
- expect ( configuration_script_source . git_repository . name ) . to eq "bar"
467
-
468
- configuration_script_source . scm_url = "https://example.com/bar.git"
469
- expect ( configuration_script_source . git_repository . url ) . to eq "https://example.com/bar.git"
470
-
471
- configuration_script_source . authentication = nil
472
- expect ( configuration_script_source . git_repository . authentication ) . to be_nil
473
- end
474
-
475
- it "persists attributes down" do
476
- configuration_script_source . update! ( :name => "bar" )
477
- expect ( GitRepository . first . name ) . to eq "bar"
478
-
479
- configuration_script_source . update! ( :scm_url => "https://example.com/bar.git" )
480
- expect ( GitRepository . first . url ) . to eq "https://example.com/bar.git"
481
-
482
- configuration_script_source . update! ( :authentication => nil )
483
- expect ( GitRepository . first . authentication ) . to be_nil
484
- end
485
- end
486
329
end
0 commit comments