diff options
Diffstat (limited to 'test/system')
| -rw-r--r-- | test/system/comments_test.rb | 22 | ||||
| -rw-r--r-- | test/system/exports_test.rb | 5 | ||||
| -rw-r--r-- | test/system/searches_test.rb | 19 | ||||
| -rw-r--r-- | test/system/shared_searches_test.rb | 6 | ||||
| -rw-r--r-- | test/system/tags_test.rb | 3 | ||||
| -rw-r--r-- | test/system/things_test.rb | 25 |
6 files changed, 56 insertions, 24 deletions
diff --git a/test/system/comments_test.rb b/test/system/comments_test.rb index b2490b4..33a1398 100644 --- a/test/system/comments_test.rb +++ b/test/system/comments_test.rb @@ -12,9 +12,11 @@ class CommentsTest < ApplicationSystemTestCase visit thing_url(things(:thing1)) click_on I18n.t('comments.new') + assert_text I18n.t('tags.new-action'), count: 1 click_on I18n.t('general.cancel') + assert_text I18n.t('tags.new-action'), count: 0 end @@ -28,10 +30,9 @@ class CommentsTest < ApplicationSystemTestCase click_on I18n.t('helpers.submit.create') - assert_text "#{I18n.t('comments.title')} #2" assert_text 'a new comment' assert_text "#{I18n.t('tags.title')}: #{tags(:tag1).name}, #{tags(:tag2).name}" - assert page.current_path == thing_path(things(:thing1)) + assert_equal page.current_path, thing_path(things(:thing1)) end test 'things#show: you can update a comment' do @@ -41,16 +42,18 @@ class CommentsTest < ApplicationSystemTestCase find(:css, '#comment_content').set('updated comment') find("#comment_#{comments(:comment1).id} input[type=submit]").click + assert_text 'updated comment' - assert page.current_path == thing_path(things(:thing1)) + assert_equal page.current_path, thing_path(things(:thing1)) end test 'things#show: you can delete a comment' do visit thing_url(things(:thing1)) all('.delete-comment').last.click + assert_text I18n.t('comments.none') - assert page.current_path == thing_path(things(:thing1)) + assert_equal page.current_path, thing_path(things(:thing1)) end ## @@ -60,9 +63,11 @@ class CommentsTest < ApplicationSystemTestCase visit edit_thing_url(things(:thing1)) click_on I18n.t('comments.new') + assert_text I18n.t('tags.new-action'), count: 2 click_on I18n.t('general.cancel') + assert_text I18n.t('tags.new-action'), count: 1 end @@ -76,10 +81,9 @@ class CommentsTest < ApplicationSystemTestCase click_on I18n.t('helpers.submit.create') - assert_text "#{I18n.t('comments.title')} #2" assert_text 'a new comment' assert_text "#{I18n.t('tags.title')}: #{tags(:tag1).name}, #{tags(:tag2).name}" - assert page.current_path == edit_thing_path(things(:thing1)) + assert_equal page.current_path, edit_thing_path(things(:thing1)) end test 'things#edit: you can update a comment' do @@ -89,15 +93,17 @@ class CommentsTest < ApplicationSystemTestCase find(:css, '#comment_content').set('updated comment') find("#comment_#{comments(:comment1).id} input[type=submit]").click + assert_text 'updated comment' - assert page.current_path == edit_thing_path(things(:thing1)) + assert_equal page.current_path, edit_thing_path(things(:thing1)) end test 'things#edit: you can delete a comment' do visit edit_thing_url(things(:thing1)) all('.delete-comment').last.click + assert_text I18n.t('comments.none') - assert page.current_path == edit_thing_path(things(:thing1)) + assert_equal page.current_path, edit_thing_path(things(:thing1)) end end diff --git a/test/system/exports_test.rb b/test/system/exports_test.rb index b324321..fea3dad 100644 --- a/test/system/exports_test.rb +++ b/test/system/exports_test.rb @@ -9,11 +9,13 @@ class ExportsTest < ApplicationSystemTestCase test 'can access exports from the hidden menu' do find('#toggle-hidden-global-menu').click + assert_text I18n.t('searches.export.action') click_on I18n.t('searches.export.action') + assert_text I18n.t('searches.export.note-msg') - assert page.current_path == new_search_exports_path(0) + assert_equal page.current_path, new_search_exports_path(0) end test 'can export using multiple formats' do @@ -22,6 +24,7 @@ class ExportsTest < ApplicationSystemTestCase assert find('#export-format-button')[:href].ends_with?('/searches/0/exports.csv') find('#export-select-format').select('UOC') + assert find('#export-format-button')[:href].ends_with?('/searches/0/exports.uoc') end end diff --git a/test/system/searches_test.rb b/test/system/searches_test.rb index a400e71..309d51c 100644 --- a/test/system/searches_test.rb +++ b/test/system/searches_test.rb @@ -21,11 +21,13 @@ class SearchesTest < ApplicationSystemTestCase test 'the hidden menu should allow us to go into the searches#new url' do find('#toggle-hidden-global-menu').click + assert_text I18n.t('searches.title') click_on I18n.t('searches.object') + assert find('#search_body') - assert page.current_path == new_search_path + assert_equal page.current_path, new_search_path end test 'can perform a new search' do @@ -56,22 +58,25 @@ class SearchesTest < ApplicationSystemTestCase # Hit the save button so the hidden form appears. assert_text I18n.t('searches.save') find('#save-search').click + assert_text I18n.t('searches.public') fill_in 'Name', with: 'Nova cerca' click_on I18n.t('helpers.submit.create') assert_text 'Nova cerca' - assert page.current_path == search_path(Search.find_by(name: 'Nova cerca')) + assert_equal page.current_path, search_path(Search.find_by(name: 'Nova cerca')) end test 'can edit a search that is not the Home' do # Home cannot be edited. find('#toggle-hidden-global-menu').click + assert_selector 'a', text: I18n.t('general.edit'), count: 0 # Select search1 click_on searches(:search1).name + assert_selector 'a', text: things(:thing1).title, count: 2 find('#toggle-hidden-global-menu').click @@ -81,7 +86,7 @@ class SearchesTest < ApplicationSystemTestCase # If you click on it, you will be on the edit page for it. assert find('#search_body') - assert page.current_path == edit_search_path(searches(:search1)) + assert_equal page.current_path, edit_search_path(searches(:search1)) end test 'edit an existing search works' do @@ -92,6 +97,7 @@ class SearchesTest < ApplicationSystemTestCase # Hit the save button so the hidden form appears. assert_text I18n.t('searches.save') find('#save-search').click + assert_text I18n.t('searches.public') # Update the name. @@ -101,23 +107,26 @@ class SearchesTest < ApplicationSystemTestCase # We have been redirected to search#show, and the name has been refreshed. assert_selector 'a', text: searches(:search1).name, count: 0 assert_text 'Nova cerca' - assert page.current_path == search_path(searches(:search1)) + assert_equal page.current_path, search_path(searches(:search1)) end test 'can delete a search that is not the Home' do # Home cannot be deleted. find('#toggle-hidden-global-menu').click + assert_selector 'a', text: I18n.t('general.delete'), count: 0 # Select search1 click_on searches(:search1).name + assert_selector 'a', text: things(:thing1).title, count: 2 find('#toggle-hidden-global-menu').click # It can be deleted! assert_text I18n.t('general.delete') accept_alert { click_on I18n.t('general.delete') } + assert_selector 'a', text: searches(:search1).name, count: 0 - assert Search.none? + assert_predicate Search, :none? end end diff --git a/test/system/shared_searches_test.rb b/test/system/shared_searches_test.rb index 0cfc4bd..6828dbe 100644 --- a/test/system/shared_searches_test.rb +++ b/test/system/shared_searches_test.rb @@ -7,9 +7,11 @@ class SharedSearchesTest < ApplicationSystemTestCase sign_in! find('#toggle-hidden-global-menu').click + assert_text I18n.t('searches.shared.title').downcase click_on I18n.t('searches.shared.title').downcase + assert_text I18n.t('searches.shared.none') end @@ -17,8 +19,9 @@ class SharedSearchesTest < ApplicationSystemTestCase sign_out_maybe! visit shared_searches_path + assert_text I18n.t('sessions.title') - assert page.current_path == new_sessions_path + assert_equal page.current_path, new_sessions_path end test 'shared_searches#show gives us the expected results' do @@ -27,6 +30,7 @@ class SharedSearchesTest < ApplicationSystemTestCase searches(:search1).update!(shared: true) visit search_shared_path(searches(:search1)) + assert_text things(:thing1).title assert_text things(:thing2).title assert_text I18n.t('comments.title') diff --git a/test/system/tags_test.rb b/test/system/tags_test.rb index 1ee83a9..8789087 100644 --- a/test/system/tags_test.rb +++ b/test/system/tags_test.rb @@ -17,6 +17,7 @@ class SharedSearchesTest < ApplicationSystemTestCase fill_in I18n.t('activerecord.attributes.tag.name'), with: 'whatever' assert_difference 'Tag.count' do click_on I18n.t('helpers.submit.create') + assert_text 'whatever' end end @@ -26,6 +27,7 @@ class SharedSearchesTest < ApplicationSystemTestCase fill_in I18n.t('activerecord.attributes.tag.name'), with: tags(:tag1).name click_on I18n.t('helpers.submit.create') + assert_text "#{I18n.t('activerecord.attributes.tag.name')} #{I18n.t('errors.messages.taken')}" end @@ -34,6 +36,7 @@ class SharedSearchesTest < ApplicationSystemTestCase assert_difference 'Tag.count', -1 do click_link(I18n.t('general.delete'), match: :first) + assert_text I18n.t('tags.title') end end diff --git a/test/system/things_test.rb b/test/system/things_test.rb index 9dd482d..792c07f 100644 --- a/test/system/things_test.rb +++ b/test/system/things_test.rb @@ -7,12 +7,14 @@ class ThingsTest < ApplicationSystemTestCase test 'the hidden menu has a things#new link' do find('#toggle-hidden-global-menu').click + assert_text I18n.t('things.object').downcase click_on I18n.t('things.object').downcase + assert_text I18n.t('activerecord.attributes.thing.title') - assert page.current_path == new_thing_path + assert_equal page.current_path, new_thing_path end test 'you can click on a thing listed on the search to go to the its #show page' do @@ -20,7 +22,7 @@ class ThingsTest < ApplicationSystemTestCase assert_text I18n.t('activerecord.attributes.thing.title') - assert page.current_path == edit_thing_path(things(:thing1)) + assert_equal page.current_path, edit_thing_path(things(:thing1)) end test 'you can create a new thing' do @@ -38,13 +40,17 @@ class ThingsTest < ApplicationSystemTestCase # Ensure that tag references are properly created. tags = Thing.find_by(title: 'new title').tags - assert tags.size == 1 - assert tags.first.name == tags(:tag1).name - # You can go back to create another thing with a convenient link. + assert_equal tags.map(&:name), [tags(:tag1).name] + end + + test 'you have a link to go back at creating a thing' do + visit thing_url(things(:thing1)) + click_on I18n.t('things.create-another') + assert_text I18n.t('activerecord.attributes.thing.title') - assert page.current_path == new_thing_path + assert_equal page.current_path, new_thing_path end test 'you get feedback from wrong values for a new thing' do @@ -67,7 +73,7 @@ class ThingsTest < ApplicationSystemTestCase # Originally :thing1 has references to :tag1 and :tag2. This test will # remove the reference to :tag1. - assert things(:thing1).tag_references.size == 2 + assert_equal 2, things(:thing1).tag_references.size fill_in I18n.t('activerecord.attributes.thing.title'), with: 'another thing entirely' find("#thing_tag_ids_#{tags(:tag1).id}").click @@ -77,8 +83,8 @@ class ThingsTest < ApplicationSystemTestCase # Tag references updated: only one reference (:tag2). tags = things(:thing1).reload.tags - assert tags.size == 1 - assert tags.first.id = tags(:tag2).id + + assert_equal tags.map(&:id), [tags(:tag2).id] end test 'you get feedback from wrong values for a thing' do @@ -96,6 +102,7 @@ class ThingsTest < ApplicationSystemTestCase assert_difference 'Thing.count', -1 do accept_alert { click_on I18n.t('general.delete').capitalize, match: :first } + assert_text I18n.t('things.destroy-success') end end |
