ToolJet/test/controllers/application_controller_test.rb
Deepti Kakade b10d777f63
Fixes Rubocop issues in tests (#359)
* Updated project set up guide for Mac, added node version and Webpack install steps.

* Worked on PR comment i.e Can we change this line to Install Node.js ( version: v14.9.0 )

* Fixed "Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping."

* Resolved rubocop comments i.e "Style/FrozenStringLiteralComment: Missing frozen string literal comment." in test folder

Co-authored-by: Deepti Kakade <deepti@saeloun.com>
Co-authored-by: Deepti Kakade <“deepti@saeloun.com”>
2021-07-01 12:54:35 +05:30

28 lines
1 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ApplicationControllerTest < ActionDispatch::IntegrationTest
def setup
@org = Organization.create({ name: "ToolJet Test" })
@org_admin = User.create({ first_name: "Admin", email: "admin@example.com", password: "password",
organization: @org })
@admin_org_user = OrganizationUser.create(organization: @org, user: @org_admin, role: "admin", status: "active")
end
test "active users can access authenticated routes" do
app = App.create(name: "Test App", organization: @org)
get apps_url, headers: { "Content-Type": "application/json" }.merge(auth_header(@org_admin)), xhr: true
assert_response 200
end
test "archived users cannot access authenticated routes" do
@admin_org_user.update(status: "archived")
@admin_org_user.reload
app = App.create(name: "Test App", organization: @org)
get apps_url, headers: { "Content-Type": "application/json" }.merge(auth_header(@org_admin)), xhr: true
assert_response 401
end
end