Skip to content

Commit

Permalink
fix: edge API not updated when versioned change request committed (#3760
Browse files Browse the repository at this point in the history
)
  • Loading branch information
matthewelwell authored Apr 17, 2024
1 parent bac3b0f commit a7ee657
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
10 changes: 7 additions & 3 deletions api/features/workflows/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
create_feature_state_updated_by_change_request_audit_log,
create_feature_state_went_live_audit_log,
)
from environments.tasks import rebuild_environment_document
from features.models import FeatureState
from features.versioning.models import EnvironmentFeatureVersion
from features.versioning.tasks import trigger_update_version_webhooks

from ...versioning.models import EnvironmentFeatureVersion
from .exceptions import (
from features.workflows.core.exceptions import (
CannotApproveOwnChangeRequest,
ChangeRequestDeletionError,
ChangeRequestNotApprovedError,
Expand Down Expand Up @@ -165,6 +165,10 @@ def _publish_environment_feature_versions(
},
delay_until=environment_feature_version.live_from,
)
rebuild_environment_document.delay(
kwargs={"environment_id": self.environment_id},
delay_until=environment_feature_version.live_from,
)

def get_create_log_message(self, history_instance) -> typing.Optional[str]:
return CHANGE_REQUEST_CREATED_MESSAGE % self.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from django.contrib.sites.models import Site
from django.utils import timezone
from pytest_mock import MockerFixture

from audit.constants import (
CHANGE_REQUEST_APPROVED_MESSAGE,
Expand Down Expand Up @@ -582,7 +583,10 @@ def test_change_request_group_assignment_sends_notification_emails_to_group_user

@pytest.mark.freeze_time(now)
def test_commit_change_request_publishes_environment_feature_versions(
environment: Environment, feature: Feature, admin_user: FFAdminUser
environment: Environment,
feature: Feature,
admin_user: FFAdminUser,
mocker: MockerFixture,
):
# Given
environment.use_v2_feature_versioning = True
Expand All @@ -603,6 +607,13 @@ def test_commit_change_request_publishes_environment_feature_versions(

change_request.environment_feature_versions.add(environment_feature_version)

mock_rebuild_environment_document_task = mocker.patch(
"features.workflows.core.models.rebuild_environment_document"
)
mock_trigger_update_version_webhooks = mocker.patch(
"features.workflows.core.models.trigger_update_version_webhooks"
)

# When
change_request.commit(admin_user)

Expand All @@ -612,6 +623,17 @@ def test_commit_change_request_publishes_environment_feature_versions(
assert environment_feature_version.published_by == admin_user
assert environment_feature_version.live_from == now

mock_rebuild_environment_document_task.delay.assert_called_once_with(
kwargs={"environment_id": environment.id},
delay_until=environment_feature_version.live_from,
)
mock_trigger_update_version_webhooks.delay.assert_called_once_with(
kwargs={
"environment_feature_version_uuid": str(environment_feature_version.uuid)
},
delay_until=environment_feature_version.live_from,
)


def test_cannot_delete_committed_change_request(
change_request: ChangeRequest, admin_user: FFAdminUser
Expand Down

0 comments on commit a7ee657

Please sign in to comment.