|
160 | 160 | .to eq(request_body.dig(:workspace, :organization_id))
|
161 | 161 | expect(response_hash.dig(:data, :attributes, :members_count))
|
162 | 162 | .to eq(workspace.users.count)
|
| 163 | + |
| 164 | + audit_log = AuditLog.last |
| 165 | + expect(audit_log).not_to be_nil |
| 166 | + expect(audit_log.user_id).to eq(user.id) |
| 167 | + expect(audit_log.action).to eq("create") |
| 168 | + expect(audit_log.resource_type).to eq("Workspace") |
| 169 | + expect(audit_log.resource_id).to eq(response_hash.dig(:data, :id).to_i) |
| 170 | + expect(audit_log.resource).to eq(response_hash.dig(:data, :attributes, :name)) |
| 171 | + expect(audit_log.workspace_id).to eq(workspace_id) |
| 172 | + expect(audit_log.resource_link).to eq("/reports/#{response_hash.dig(:data, :id)}") |
| 173 | + expect(audit_log.created_at).not_to be_nil |
| 174 | + expect(audit_log.updated_at).not_to be_nil |
163 | 175 | end
|
164 | 176 |
|
165 | 177 | it "creates a new workspace and returns success for member_role" do
|
|
216 | 228 | expect(response_hash.dig(:data, :attributes, :name)).to eq("test")
|
217 | 229 | expect(response_hash.dig(:data, :attributes, :description)).to eq("workspace description changes")
|
218 | 230 | expect(response_hash.dig(:data, :attributes, :region)).to eq("us-west2")
|
| 231 | + |
| 232 | + audit_log = AuditLog.last |
| 233 | + expect(audit_log).not_to be_nil |
| 234 | + expect(audit_log.user_id).to eq(user.id) |
| 235 | + expect(audit_log.action).to eq("update") |
| 236 | + expect(audit_log.resource_type).to eq("Workspace") |
| 237 | + expect(audit_log.resource_id).to eq(response_hash.dig(:data, :id).to_i) |
| 238 | + expect(audit_log.resource).to eq(response_hash.dig(:data, :attributes, :name)) |
| 239 | + expect(audit_log.workspace_id).to eq(workspace_id) |
| 240 | + expect(audit_log.resource_link).to eq("/reports/#{response_hash.dig(:data, :id)}") |
| 241 | + expect(audit_log.created_at).not_to be_nil |
| 242 | + expect(audit_log.updated_at).not_to be_nil |
219 | 243 | end
|
220 | 244 |
|
221 | 245 | it "updates the workspace and returns success if slug is missing" do
|
|
230 | 254 | expect(response_hash.dig(:data, :attributes, :name)).to eq("test")
|
231 | 255 | expect(response_hash.dig(:data, :attributes, :description)).to eq("workspace description changes")
|
232 | 256 | expect(response_hash.dig(:data, :attributes, :region)).to eq("us-west2")
|
| 257 | + |
| 258 | + audit_log = AuditLog.last |
| 259 | + expect(audit_log).not_to be_nil |
| 260 | + expect(audit_log.user_id).to eq(user.id) |
| 261 | + expect(audit_log.action).to eq("update") |
| 262 | + expect(audit_log.resource_type).to eq("Workspace") |
| 263 | + expect(audit_log.resource_id).to eq(response_hash.dig(:data, :id).to_i) |
| 264 | + expect(audit_log.resource).to eq(response_hash.dig(:data, :attributes, :name)) |
| 265 | + expect(audit_log.workspace_id).to eq(workspace_id) |
| 266 | + expect(audit_log.resource_link).to eq("/reports/#{response_hash.dig(:data, :id)}") |
| 267 | + expect(audit_log.created_at).not_to be_nil |
| 268 | + expect(audit_log.updated_at).not_to be_nil |
233 | 269 | end
|
234 | 270 |
|
235 | 271 | it "updates the workspace and returns success for viewer_role" do
|
|
275 | 311 | it "returns success and delete workspace" do
|
276 | 312 | delete "/api/v1/workspaces/#{workspace.id}", headers: auth_headers(user, workspace_id)
|
277 | 313 | expect(response).to have_http_status(:no_content)
|
| 314 | + |
| 315 | + audit_log = AuditLog.last |
| 316 | + expect(audit_log).not_to be_nil |
| 317 | + expect(audit_log.user_id).to eq(user.id) |
| 318 | + expect(audit_log.action).to eq("delete") |
| 319 | + expect(audit_log.resource_type).to eq("Workspace") |
| 320 | + expect(audit_log.resource_id).to eq(workspace_id) |
| 321 | + expect(audit_log.resource).to eq(workspace.name) |
| 322 | + expect(audit_log.workspace_id).to eq(nil) |
| 323 | + expect(audit_log.resource_link).to eq(nil) |
| 324 | + expect(audit_log.created_at).not_to be_nil |
| 325 | + expect(audit_log.updated_at).not_to be_nil |
278 | 326 | end
|
279 | 327 |
|
280 | 328 | it "returns success and delete workspace for viewer_role" do
|
|
0 commit comments