Skip to content

Commit

Permalink
Add simple unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mirrec committed Dec 4, 2023
1 parent b1274af commit 8b033c3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
8 changes: 4 additions & 4 deletions test/fixtures/group_memberships.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
ssd_basic_basic_user:
user: basic
group: basic_user
group: ssd_basic_user

two:
ssd_basic_all:
user: basic
group: all
group: ssd_all
13 changes: 9 additions & 4 deletions test/fixtures/groups.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

all:
ssd_all:
name: all
type: AllGroup
tenant: ssd

admins:
ssd_admins:
name: admins
type: AdminGroup
tenant: ssd

basic_user:
name: "Basic user"
ssd_basic_user:
name: Basic user
type: UserGroup
tenant: ssd

ssd_signers:
name: Podpisovaci
type: SignerGroup
tenant: ssd

solver_admin:
name: admins
type: AdminGroup
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/tag_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

finance_basic_user:
tag: ssd_finance
group: basic_user
group: ssd_basic_user

#two:
# tag: two
12 changes: 12 additions & 0 deletions test/fixtures/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ ssd_print:
visible: true
tenant: ssd

ssd_signature_requested:
name: Na podpis
type: SignatureRequestedTag
visible: true
tenant: ssd

ssd_signed:
name: Podpisane
type: SignedTag
visible: true
tenant: ssd

solver_special:
name: Special
type: SimpleTag
Expand Down
14 changes: 14 additions & 0 deletions test/models/group_membership_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "test_helper"

class GroupMembershipTest < ActiveSupport::TestCase
test 'after create callback creates signature tags for a user if the user is added to the signers group' do
user = users(:basic)
signers_group = groups(:ssd_signers)

GroupMembership.create!(user: user, group: signers_group)

user.reload
assert user.signature_requested_to_tag
assert user.signed_by_tag
end
end

0 comments on commit 8b033c3

Please sign in to comment.