From 5076056e3789467d1412b0312794a747b2ea805f Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 19 Mar 2024 22:05:35 +0100 Subject: things: added missing tests for the js controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- test/system/things_test.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test/system') diff --git a/test/system/things_test.rb b/test/system/things_test.rb index 8b25913..dafe45d 100644 --- a/test/system/things_test.rb +++ b/test/system/things_test.rb @@ -106,4 +106,50 @@ class ThingsTest < ApplicationSystemTestCase assert_text I18n.t('things.destroy-success') end end + + test '"access" appears/disappears whenever "url" is set/unset' do + visit edit_thing_url(things(:thing1)) + + assert_text I18n.t('activerecord.attributes.thing.access') + + fill_in I18n.t('activerecord.attributes.thing.url'), with: '' + + assert_text I18n.t('activerecord.attributes.thing.access'), count: 0 + + fill_in I18n.t('activerecord.attributes.thing.url'), with: 'whatever' + + assert_text I18n.t('activerecord.attributes.thing.access') + end + + test '"target" gets generated from last name' do + visit new_thing_url + + fill_in I18n.t('activerecord.attributes.thing.authors'), with: 'Name LastName' + + text = find_field(I18n.t('activerecord.attributes.thing.target')).value + + assert_equal 'LastName', text + end + + test '"target" gets generated from last name and year' do + visit new_thing_url + + fill_in I18n.t('activerecord.attributes.thing.authors'), with: 'Name LastName' + fill_in I18n.t('activerecord.attributes.thing.year'), with: '2024' + + text = find_field(I18n.t('activerecord.attributes.thing.target')).value + + assert_equal 'LastName2024', text + end + + test '"target" gets generated from multiple names and year' do + visit new_thing_url + + fill_in I18n.t('activerecord.attributes.thing.authors'), with: 'Name LastName, John Smith' + fill_in I18n.t('activerecord.attributes.thing.year'), with: '2024' + + text = find_field(I18n.t('activerecord.attributes.thing.target')).value + + assert_equal 'LastNameSmith2024', text + end end -- cgit v1.2.3