DEV: correct heisentest

DEV: correct heisentest

This test failed IF this category id number 3 was fabricated to start with at the top of the test.

This is very likely if the test is run on a blank DB

diff --git a/spec/requests/admin/embeddable_hosts_controller_spec.rb b/spec/requests/admin/embeddable_hosts_controller_spec.rb
index 3f90af8..fc7353a 100644
--- a/spec/requests/admin/embeddable_hosts_controller_spec.rb
+++ b/spec/requests/admin/embeddable_hosts_controller_spec.rb
@@ -27,22 +27,22 @@ describe Admin::EmbeddableHostsController do
 
     describe '#update' do
       it "logs embeddable host update" do
+
+        category = Fabricate(:category)
+
         put "/admin/embeddable_hosts/#{embeddable_host.id}.json", params: {
-          embeddable_host: { host: "test.com", class_name: "test-class", category_id: "3" }
+          embeddable_host: { host: "test.com", class_name: "test-class", category_id: category.id }
         }
 
         expect(response.status).to eq(200)
 
-        if (!UserHistory.where(
+        history_exists = UserHistory.where(
             acting_user_id: admin.id,
             action: UserHistory.actions[:embeddable_host_update],
-            new_value: "host: test.com, class_name: test-class, category_id: 3").exists?)
+            new_value: "host: test.com, class_name: test-class, category_id: #{category.id}").exists?
+
+        expect(history_exists).to eq(true)
 
-          puts "heisentest just failed, debug info is:"
-          puts "count: #{UserHistory.count}"
-          puts "data: #{UserHistory.all.map(&:to_json).join("\n")}"
-          expect("erracit test").to eq("erratic test")
-        end
       end
     end

GitHub sha: 17b34f57

1 Like