Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Use match_array for spec allowed groups #520

Merged
merged 1 commit into from
Nov 2, 2023
Merged

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented Nov 2, 2023

A fix for this error:

1) Assigner invite_on_assign doesn't invite group if all members have access to the PM already
     Failure/Error: expect(topic.allowed_groups).to eq([group1, group2])
     
       expected: [#<Group id: 88, name: "my_group_47", created_at: "2023-11-02 06:04:13.051487280 +0000", updated_at: "2023-11-02 06:04:13.051487280 +0000", automatic: false, user_count: 0, automatic_membership_email_domains: nil, primary_group: false, title: nil, grant_trust_level: nil, incoming_email: nil, has_messages: false, flair_bg_color: nil, flair_color: nil, bio_raw: nil, bio_cooked: nil, allow_membership_requests: false, full_name: nil, default_notification_level: 3, visibility_level: 0, public_exit: false, public_admission: false, membership_request_template: nil, messageable_level: 1, mentionable_level: 0, smtp_server: nil, smtp_port: nil, smtp_ssl: nil, imap_server: nil, imap_port: nil, imap_ssl: nil, imap_mailbox_name: "", imap_uid_validity: 0, imap_last_uid: 0, email_username: nil, email_password: nil, publish_read_state: false, members_visibility_level: 0, imap_last_error: nil, imap_old_emails: nil, imap_new_emails: nil, flair_icon: nil, flair_upload_id: nil, allow_unknown_sender_topic_replies: false, smtp_enabled: false, smtp_updated_at: nil, smtp_updated_by_id: nil, imap_enabled: false, imap_updated_at: nil, imap_updated_by_id: nil, email_from_alias: nil, assignable_level: 1>, #<Group id: 89, name: "my_group_48", created_at: "2023-11-02 06:04:13.057429679 +0000", updated_at: "2023-11-02 06:04:13.057429679 +0000", automatic: false, user_count: 0, automatic_membership_email_domains: nil, primary_group: false, title: nil, grant_trust_level: nil, incoming_email: nil, has_messages: false, flair_bg_color: nil, flair_color: nil, bio_raw: nil, bio_cooked: nil, allow_membership_requests: false, full_name: nil, default_notification_level: 3, visibility_level: 0, public_exit: false, public_admission: false, membership_request_template: nil, messageable_level: 1, mentionable_level: 0, smtp_server: nil, smtp_port: nil, smtp_ssl: nil, imap_server: nil, imap_port: nil, imap_ssl: nil, imap_mailbox_name: "", imap_uid_validity: 0, imap_last_uid: 0, email_username: nil, email_password: nil, publish_read_state: false, members_visibility_level: 0, imap_last_error: nil, imap_old_emails: nil, imap_new_emails: nil, flair_icon: nil, flair_upload_id: nil, allow_unknown_sender_topic_replies: false, smtp_enabled: false, smtp_updated_at: nil, smtp_updated_by_id: nil, imap_enabled: false, imap_updated_at: nil, imap_updated_by_id: nil, email_from_alias: nil, assignable_level: 1>]
            got: #<ActiveRecord::Associations::CollectionProxy [#<Group id: 89, name: "my_group_48", created_at: "2023-11-02 06:04:13.057429000 +0000", updated_at: "2023-11-02 06:04:13.057429000 +0000", automatic: false, user_count: 2, automatic_membership_email_domains: nil, primary_group: false, title: nil, grant_trust_level: nil, incoming_email: nil, has_messages: false, flair_bg_color: nil, flair_color: nil, bio_raw: nil, bio_cooked: nil, allow_membership_requests: false, full_name: nil, default_notification_level: 3, visibility_level: 0, public_exit: false, public_admission: false, membership_request_template: nil, messageable_level: 1, mentionable_level: 0, smtp_server: nil, smtp_port: nil, smtp_ssl: nil, imap_server: nil, imap_port: nil, imap_ssl: nil, imap_mailbox_name: "", imap_uid_validity: 0, imap_last_uid: 0, email_username: nil, email_password: nil, publish_read_state: false, members_visibility_level: 0, imap_last_error: nil, imap_old_emails: nil, imap_new_emails: nil, flair_icon: nil, flair_upload_id: nil, allow_unknown_sender_topic_replies: false, smtp_enabled: false, smtp_updated_at: nil, smtp_updated_by_id: nil, imap_enabled: false, imap_updated_at: nil, imap_updated_by_id: nil, email_from_alias: nil, assignable_level: 1>, #<Group id: 88, name: "my_group_47", created_at: "2023-11-02 06:04:13.051487000 +0000", updated_at: "2023-11-02 06:04:13.051487000 +0000", automatic: false, user_count: 2, automatic_membership_email_domains: nil, primary_group: false, title: nil, grant_trust_level: nil, incoming_email: nil, has_messages: false, flair_bg_color: nil, flair_color: nil, bio_raw: nil, bio_cooked: nil, allow_membership_requests: false, full_name: nil, default_notification_level: 3, visibility_level: 0, public_exit: false, public_admission: false, membership_request_template: nil, messageable_level: 1, mentionable_level: 0, smtp_server: nil, smtp_port: nil, smtp_ssl: nil, imap_server: nil, imap_port: nil, imap_ssl: nil, imap_mailbox_name: "", imap_uid_validity: 0, imap_last_uid: 0, email_username: nil, email_password: nil, publish_read_state: false, members_visibility_level: 0, imap_last_error: nil, imap_old_emails: nil, imap_new_emails: nil, flair_icon: nil, flair_upload_id: nil, allow_unknown_sender_topic_replies: false, smtp_enabled: false, smtp_updated_at: nil, smtp_updated_by_id: nil, imap_enabled: false, imap_updated_at: nil, imap_updated_by_id: nil, email_from_alias: nil, assignable_level: 1>]>
     
       (compared using ==)

Copy link
Contributor

@CvX CvX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅, though I'd prefer the API to have stable return values 😅

@nattsw
Copy link
Contributor Author

nattsw commented Nov 2, 2023

@CvX I may be wrong but are you referring to this when you refer to API?

https://github.com/discourse/discourse/blob/main/app/models/topic.rb#L252

@CvX
Copy link
Contributor

CvX commented Nov 2, 2023

Yeah, a default sort there would be great, but I'm not sure about perf consequences (is it used in some hot path? what is the max number of records? etc.) so fixing a spec is cool with me 😛

@nattsw nattsw merged commit 20cdd5a into main Nov 2, 2023
5 checks passed
@nattsw nattsw deleted the fix-spec-order-array branch November 2, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants