Business intelligence made simple
Test permissions
Andrew Kane6bd6441eddc4
diff --git a/test/internal/app/controllers/application_controller.rb b/test/internal/app/controllers/application_controller.rbindex 09705d12..75cf2087 100644--- a/test/internal/app/controllers/application_controller.rb+++ b/test/internal/app/controllers/application_controller.rb@@ -1,2 +1,5 @@class ApplicationController < ActionController::Base+ def current_user+ User.last+ endenddiff --git a/test/internal/app/models/user.rb b/test/internal/app/models/user.rbnew file mode 100644index 00000000..4a57cf07--- /dev/null+++ b/test/internal/app/models/user.rb@@ -0,0 +1,2 @@+class User < ActiveRecord::Base+enddiff --git a/test/internal/db/schema.rb b/test/internal/db/schema.rbindex 6d6b4303..b8355bfe 100644--- a/test/internal/db/schema.rb+++ b/test/internal/db/schema.rb@@ -49,4 +49,8 @@ ActiveRecord::Schema.define dot.text :descriptiont.timestamps null: falseend++ create_table :users do |t|+ t.string :name+ endenddiff --git a/test/permissions_test.rb b/test/permissions_test.rbnew file mode 100644index 00000000..0d663bae--- /dev/null+++ b/test/permissions_test.rb@@ -0,0 +1,30 @@+require_relative "test_helper"++class PermissionsTest < ActionDispatch::IntegrationTest+ def setup+ Blazer::Query.delete_all+ User.delete_all+ end++ def test_list+ with_new_user do |user|+ create_query(name: "# Test", creator: user)+ get blazer.root_path+ assert_response :success+ assert_match "# Test", response.body+ end++ with_new_user do+ get blazer.root_path+ assert_response :success+ refute_match "# Test", response.body+ end+ end++ private++ def with_new_user+ user = User.create!+ yield user+ end+enddiff --git a/test/test_helper.rb b/test/test_helper.rbindex fe78e408..f662c503 100644--- a/test/test_helper.rb+++ b/test/test_helper.rb@@ -23,8 +23,8 @@ class ActionDispatch::IntegrationTestassert_response :successend- def create_query(statement: "SELECT 1")- Blazer::Query.create!(statement: statement, data_source: "main", status: "active")+ def create_query(statement: "SELECT 1", **attributes)+ Blazer::Query.create!(statement: statement, data_source: "main", status: "active", **attributes)enddef create_check(**attributes)