From 716629dc0affb7887efbd2d9b765aaf34055ab1d Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Tue, 9 Jun 2020 17:40:41 +1000 Subject: [PATCH] DEV: correct flaky test relying on possibly valid user id This test lasted about 7 years prior to it becoming flaky. Today ... for whatever reason the test suite created 100 users prior to running this spec. So the new user becomes user id 101 And... lo and behold: ``` 1) PostSerializer a hidden post with add_raw enabled a hidden post shows the raw post only if authorized to see it Failure/Error: expect(serialized_post_for_user(Fabricate(:user))[:raw]).to eq(nil) expected: nil got: "Raw contents of the post." (compared using ==) # ./spec/serializers/post_serializer_spec.rb:127:in `block (4 levels) in
' ``` --- spec/serializers/post_serializer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb index 91ca676ecd..dc633ba80c 100644 --- a/spec/serializers/post_serializer_spec.rb +++ b/spec/serializers/post_serializer_spec.rb @@ -106,7 +106,7 @@ describe PostSerializer do end context "a hidden post with add_raw enabled" do - let(:user) { Fabricate.build(:user, id: 101) } + let(:user) { Fabricate.build(:user, id: -99999) } let(:raw) { "Raw contents of the post." } context "a public post" do