Skip to content

Commit

Permalink
Merge pull request #159 from ps2611/cb-268/new-revision
Browse files Browse the repository at this point in the history
CB-268: Update review only if contents are edited
  • Loading branch information
paramsingh committed Feb 19, 2018
2 parents b79e252 + 62d0a3d commit d6f5048
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion critiquebrainz/frontend/views/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ def edit(id):
# Can't change license if review is published.
del form.license_choice

if form.validate_on_submit():
# Check if contents of the review are updated
if form.text.data == review['text'] and form.rating.data == review['rating']:
form.errors['edit'] = ["You must edit either text or rating to update the review."]
elif form.validate_on_submit():
if review["is_draft"]:
license_choice = form.license_choice.data
else:
Expand Down
6 changes: 6 additions & 0 deletions critiquebrainz/frontend/views/test/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def test_edit(self):
self.assert200(response)
self.assertIn(updated_text, str(response.data))

# edit once again with the same test and check for error
response = self.client.post('/review/%s/edit' % review['id'], data=data,
query_string=data, follow_redirects=True)
self.assert200(response)
self.assertIn('You must edit either text or rating to update the review.', str(response.data))

def test_delete(self):
review = self.create_dummy_review()

Expand Down

0 comments on commit d6f5048

Please sign in to comment.