mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-11 03:00:43 +00:00
* 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”>
50 lines
2.4 KiB
Ruby
50 lines
2.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
class FolderAppsControllerTest < ActionDispatch::IntegrationTest
|
|
def setup
|
|
@org = Organization.create({ name: "ToolJet Test" })
|
|
@admin = User.create({ first_name: "Admin", email: "admin@example.com", password: "password",
|
|
organization: @org })
|
|
@developer = User.create({ first_name: "Dev", email: "dev@example.com", password: "password",
|
|
organization: @org })
|
|
@viewer = User.create({ first_name: "Viewer", email: "viewer@example.com", password: "password",
|
|
organization: @org })
|
|
OrganizationUser.create(organization: @org, user: @admin, role: "admin", status: "active")
|
|
OrganizationUser.create(organization: @org, user: @developer, role: "developer", status: "active")
|
|
OrganizationUser.create(organization: @org, user: @viewer, role: "viewer", status: "active")
|
|
|
|
@another_org = Organization.create({ name: "Another ToolJet Test" })
|
|
@another_org_admin = User.create({ first_name: "Admin", email: "admin@domain.com", password: "password",
|
|
organization: @another_org })
|
|
OrganizationUser.create(organization: @another_org, user: @another_org_admin, role: "admin")
|
|
|
|
@folder = Folder.create(name: "Test Folder", organization: @org)
|
|
end
|
|
|
|
test "org admins can add apps to folders" do
|
|
app = App.create(name: "Test App", organization: @org)
|
|
assert_difference "FolderApp.count", 1 do
|
|
get "/folder_apps", params: { app_id: app.id, folder_id: @folder.id }, as: :json, headers: auth_header(@admin)
|
|
end
|
|
end
|
|
|
|
test "admins of a different org cannot add apps to folders" do
|
|
app = App.create(name: "Test App", organization: @org)
|
|
assert_difference "FolderApp.count", 0 do
|
|
get "/folder_apps", params: { app_id: app.id, folder_id: @folder.id }, as: :json, headers: auth_header(@another_org_admin)
|
|
end
|
|
end
|
|
|
|
test "only admins & developers can add apps to folders" do
|
|
app = App.create(name: "Test App", organization: @org)
|
|
assert_difference "FolderApp.count", 1 do
|
|
get "/folder_apps", params: { app_id: app.id, folder_id: @folder.id }, as: :json, headers: auth_header(@developer)
|
|
end
|
|
|
|
assert_difference "FolderApp.count", 0 do
|
|
get "/folder_apps", params: { app_id: app.id, folder_id: @folder.id }, as: :json, headers: auth_header(@viewer)
|
|
end
|
|
end
|
|
end
|