Skip to content

Commit

Permalink
Fix: when setting rearm on a new alert, it wasn't persisted.
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr committed Jun 28, 2017
1 parent 24ba110 commit 42116ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions redash/handlers/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from funcy import project

from redash import models
from redash.permissions import require_access, require_admin_or_owner, view_only, require_permission
from redash.handlers.base import BaseResource, require_fields, get_object_or_404
from redash.handlers.base import (BaseResource, get_object_or_404,
require_fields)
from redash.permissions import (require_access, require_admin_or_owner,
require_permission, view_only)


class AlertResource(BaseResource):
Expand Down Expand Up @@ -52,6 +54,7 @@ def post(self):
name=req['name'],
query_rel=query,
user=self.current_user,
rearm=req.get('rearm'),
options=req['options']
)

Expand Down
7 changes: 5 additions & 2 deletions tests/handlers/test_alerts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from tests import BaseTestCase
from redash.models import AlertSubscription, Alert, db

from redash.models import Alert, AlertSubscription, db


class TestAlertResourceGet(BaseTestCase):
Expand Down Expand Up @@ -92,8 +93,10 @@ def test_returns_200_if_has_access_to_query(self):
destination = self.factory.create_destination()
db.session.commit()
rv = self.make_request('post', "/api/alerts", data=dict(name='Alert', query_id=query.id,
destination_id=destination.id, options={}))
destination_id=destination.id, options={},
rearm=100))
self.assertEqual(rv.status_code, 200)
self.assertEqual(rv.json['rearm'], 100)

def test_fails_if_doesnt_have_access_to_query(self):
data_source = self.factory.create_data_source(group=self.factory.create_group())
Expand Down

0 comments on commit 42116ab

Please sign in to comment.