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

Add stack slug to organization options for direct paging #2743

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Add stack slug to organization options for direct paging Slash command by @vadimkerr ([#2743](https://github.com/grafana/oncall/pull/2743))

## v1.3.22 (2023-08-03)

### Added
Expand Down
2 changes: 1 addition & 1 deletion engine/apps/slack/scenarios/paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def _get_organization_select(
{
"text": {
"type": "plain_text",
"text": f"{org.org_title}",
"text": f"{org.org_title} ({org.stack_slug})",
"emoji": True,
},
"value": f"{org.pk}",
Expand Down
12 changes: 12 additions & 0 deletions engine/apps/slack/tests/test_scenario_steps/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
OnPagingUserChange,
Policy,
StartDirectPaging,
_get_organization_select,
)
from apps.user_management.models import Organization


def make_slack_payload(
Expand Down Expand Up @@ -401,3 +403,13 @@ def test_remove_schedule(make_organization_and_user_with_slack_identities, make_
metadata = json.loads(mock_slack_api_call.call_args.kwargs["view"]["private_metadata"])
assert metadata[DataKey.SCHEDULES] == {}
assert metadata[DataKey.USERS] == {str(user.pk): Policy.DEFAULT}


@pytest.mark.django_db
def test_get_organization_select(make_organization):
organization = make_organization(org_title="Organization", stack_slug="stack_slug")
select = _get_organization_select(Organization.objects.filter(pk=organization.pk), organization, "test")

assert len(select["element"]["options"]) == 1
assert select["element"]["options"][0]["value"] == str(organization.pk)
assert select["element"]["options"][0]["text"]["text"] == "Organization (stack_slug)"