DEV: Fix flaky time sensitive uploads.rake specs (#9283)
Also fix issues in spec where certain uploads were not considered secure
This commit is contained in:
parent
ecbccab159
commit
efd5fb665b
|
@ -768,7 +768,7 @@ def adjust_acls(uploads_to_adjust_acl_for)
|
|||
Discourse.store.update_upload_ACL(upload)
|
||||
i += 1
|
||||
end
|
||||
RakeHelpers.print_status_with_label("Updaing ACLs complete! ", i, total_count)
|
||||
RakeHelpers.print_status_with_label("Updating ACLs complete! ", i, total_count)
|
||||
end
|
||||
|
||||
def mark_all_as_secure_login_required(uploads_to_update)
|
||||
|
|
|
@ -16,4 +16,7 @@ RSpec::Matchers.define :eq_time do |expected_time|
|
|||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 millisecond of #{expected_time}"
|
||||
end
|
||||
failure_message_when_negated do |actual_time|
|
||||
"#{actual_time} is within 1 millisecond of #{expected_time}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,16 +81,19 @@ RSpec.describe "tasks/uploads" do
|
|||
expect(upload1.reload.secure).to eq(false)
|
||||
end
|
||||
|
||||
it "rebakes the posts attached" do
|
||||
post1_baked = post1.baked_at
|
||||
post2_baked = post2.baked_at
|
||||
post3_baked = post3.baked_at
|
||||
it "rebakes the posts attached for uploads that change secure status" do
|
||||
post3.topic.update(category: Fabricate(:private_category, group: Fabricate(:group)))
|
||||
freeze_time
|
||||
|
||||
post1.update_columns(baked_at: 1.week.ago)
|
||||
post2.update_columns(baked_at: 1.week.ago)
|
||||
post3.update_columns(baked_at: 1.week.ago)
|
||||
|
||||
invoke_task
|
||||
|
||||
expect(post1.reload.baked_at).not_to eq(post1_baked)
|
||||
expect(post2.reload.baked_at).not_to eq(post2_baked)
|
||||
expect(post3.reload.baked_at).not_to eq(post3_baked)
|
||||
expect(post1.reload.baked_at).to eq_time(1.week.ago)
|
||||
expect(post2.reload.baked_at).to eq_time(1.week.ago)
|
||||
expect(post3.reload.baked_at).not_to eq_time(1.week.ago)
|
||||
end
|
||||
|
||||
context "for an upload that is already secure and does not need to change" do
|
||||
|
@ -98,12 +101,17 @@ RSpec.describe "tasks/uploads" do
|
|||
post3.topic.update(archetype: 'private_message', category: nil)
|
||||
upload2.update(access_control_post: post3)
|
||||
upload2.update_secure_status
|
||||
upload3.update(access_control_post: post3)
|
||||
upload3.update_secure_status
|
||||
end
|
||||
|
||||
it "does not rebake the associated post" do
|
||||
post3_baked = post3.baked_at.to_s
|
||||
freeze_time
|
||||
|
||||
post3.update_columns(baked_at: 1.week.ago)
|
||||
invoke_task
|
||||
expect(post3.reload.baked_at.to_s).to eq(post3_baked)
|
||||
|
||||
expect(post3.reload.baked_at).to eq_time(1.week.ago)
|
||||
end
|
||||
|
||||
it "does not attempt to update the acl" do
|
||||
|
@ -168,11 +176,14 @@ RSpec.describe "tasks/uploads" do
|
|||
end
|
||||
|
||||
it "rebakes the associated posts" do
|
||||
baked_post1 = post1.baked_at
|
||||
baked_post2 = post2.baked_at
|
||||
freeze_time
|
||||
|
||||
post1.update_columns(baked_at: 1.week.ago)
|
||||
post2.update_columns(baked_at: 1.week.ago)
|
||||
invoke_task
|
||||
expect(post1.reload.baked_at).not_to eq(baked_post1)
|
||||
expect(post2.reload.baked_at).not_to eq(baked_post2)
|
||||
|
||||
expect(post1.reload.baked_at).not_to eq_time(1.week.ago)
|
||||
expect(post2.reload.baked_at).not_to eq_time(1.week.ago)
|
||||
end
|
||||
|
||||
it "updates the affected ACLs" do
|
||||
|
|
Loading…
Reference in New Issue