diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-20 16:00:18 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-20 16:00:18 +0100 |
| commit | 819f299d3bdc2485394120583b8a76a67b10b418 (patch) | |
| tree | fc7cedbcfd4f4b435649ebe35763f28ff9cc6520 /test | |
| parent | ccf588845a6e595d1c9b2726a05eddd34bc92488 (diff) | |
| download | operum-819f299d3bdc2485394120583b8a76a67b10b418.tar.gz operum-819f299d3bdc2485394120583b8a76a67b10b418.zip | |
tags: attempt to modify searches on tag rename
We don't want to break existing searches upon renaming a tag, since most
of searches will be based on tag names.
NOTE: if the UI of searches is improved, maybe the `tags:""` clause can
contain tag ids instead of names, and hence we won't need all this dance
afterwards.
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/fixtures/searches.yml | 12 | ||||
| -rw-r--r-- | test/system/searches_test.rb | 2 | ||||
| -rw-r--r-- | test/system/tags_test.rb | 12 |
3 files changed, 24 insertions, 2 deletions
diff --git a/test/fixtures/searches.yml b/test/fixtures/searches.yml index ffc7a28..81af270 100644 --- a/test/fixtures/searches.yml +++ b/test/fixtures/searches.yml @@ -1,4 +1,14 @@ search1: name: 'search1' - body: "tag:\"tag1\"" + body: 'tag:"tag1"' + user_id: <%= ActiveRecord::FixtureSet.identify(:user) %> + +search2: + name: 'search2' + body: 'tag:"tag2"' + user_id: <%= ActiveRecord::FixtureSet.identify(:user) %> + +search3: + name: 'search3' + body: 'tag:"unknown"' user_id: <%= ActiveRecord::FixtureSet.identify(:user) %> diff --git a/test/system/searches_test.rb b/test/system/searches_test.rb index 309d51c..4920102 100644 --- a/test/system/searches_test.rb +++ b/test/system/searches_test.rb @@ -127,6 +127,6 @@ class SearchesTest < ApplicationSystemTestCase accept_alert { click_on I18n.t('general.delete') } assert_selector 'a', text: searches(:search1).name, count: 0 - assert_predicate Search, :none? + assert_equal searches.size - 1, Search.count end end diff --git a/test/system/tags_test.rb b/test/system/tags_test.rb index 7e2100f..15d1c3e 100644 --- a/test/system/tags_test.rb +++ b/test/system/tags_test.rb @@ -47,6 +47,9 @@ class SharedSearchesTest < ApplicationSystemTestCase assert_text I18n.t('tags.update-success') assert_text "#{tags(:tag1).name}-updated" + + # Searches are also updated on tag renames. + assert_equal "tag:\"#{tags(:tag1).name}-updated\"", searches(:search1).body end test 'gives feedback on update errors' do @@ -58,6 +61,15 @@ class SharedSearchesTest < ApplicationSystemTestCase assert_text "#{I18n.t('activerecord.attributes.tag.name')} #{I18n.t('errors.messages.taken')}" end + test 'gives feedback when any of the searches could not be updated because of the tag rename' do + visit edit_tag_url(tags(:tag1)) + + fill_in I18n.t('activerecord.attributes.tag.name'), with: 'unknown' + click_on I18n.t('helpers.submit.update') + + assert_text I18n.t('tags.update-fail') + end + test 'can delete an existing tag' do visit tags_url |
