0

I am getting the following error when running rails tests on

WARNING: Rails was not able to disable referential integrity. This is most likely caused due to missing permissions. Rails needs superuser privileges to disable referential integrity. cause: PG::InsufficientPrivilege: ERROR: permission denied: "xxx" is a system trigger

**comment.rb**
class Comment < ApplicationRecord
  belongs_to :post
end
__________________________

**post.rb**
class Post < ApplicationRecord
    has_many :comments, dependent: :destroy
end
__________________________

**comment_test.rb**
require "test_helper"
class CommentTest < ActiveSupport::TestCase
end
______________________

**post_test.rb**

require "test_helper"

class PostTest < ActiveSupport::TestCase
end
______________________

**comments.yml**
one:
  post_id: 1
  content: MyText
  status: Active
  user_id: one

two:
  post_id: 2
  content: MyText
  status: Private
  user_id: one
_____________________

**posts.yml**
one:
  title: MyString
  content: MyText
  user_id: one
  status: active

two:
  title: MyString
  content: MyText
  user_id: one
  status: active

I have tried

  1. the change the privileges to SuperUser but Azure Postgres does not seem to allow that (see https://learn.microsoft.com/en-us/answers/questions/120659/create-superuser-in-paas-offering-of-azure-databas.html)
  2. Considered ordering the tests but this does not seem to be recommended Loading Rails Fixtures in a Specific Order when Testing
  3. Adding *.delete_all as recommended in Ruby on Rails deleting fixtures with foreign keys did not work.

Is there a cleaner / recommended way to do this without a superuser? Thank you very much in advance.

ASing
  • 45
  • 5

0 Answers0