{"id":6,"date":"2009-01-14T15:14:48","date_gmt":"2009-01-14T20:14:48","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/djcp\/?p=6"},"modified":"2009-01-14T15:14:48","modified_gmt":"2009-01-14T20:14:48","slug":"rails-22-postgres-and-testing","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/djcp\/2009\/01\/rails-22-postgres-and-testing\/","title":{"rendered":"Rails 2.2, postgres, and testing"},"content":{"rendered":"<p>If you&#8217;re using <a href=\"http:\/\/www.postgresql.org\">Postgresql<\/a> with Rails 2.2, your testing database user needs to be a &#8220;superuser&#8221; for your tests to run. <strong>This is not a good thing.<\/strong> It&#8217;s the equivalent of running as root. But, if you&#8217;ve got a completely separate development\/testing server it&#8217;s better than not being able to test at all.<\/p>\n<p>If your postgres testing user isn&#8217;t a superuser, you&#8217;ll get errors like:<\/p>\n<pre>ActiveRecord::StatementInvalid: PGError: ERROR:  permission \\\r\ndenied: \"RI_ConstraintTrigger_17866\" is a system trigger<\/pre>\n<p>You can create a postgres superuser thusly:<\/p>\n<pre>&gt; su - postgres\r\n&gt; psql template1\r\n&gt; template1=# create user  <strong>your username<\/strong> superuser;<\/pre>\n<p>Update the testing stanza of your config\/database.yml and you should be good to go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re using Postgresql with Rails 2.2, your testing database user needs to be a &#8220;superuser&#8221; for your tests to run. This is not a good thing. It&#8217;s the equivalent of running as root. But, if you&#8217;ve got a completely &hellip; <a href=\"https:\/\/archive.blogs.harvard.edu\/djcp\/2009\/01\/rails-22-postgres-and-testing\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1984,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,4166],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-code","tag-rails"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/users\/1984"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/djcp\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}