diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-19 22:05:35 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-19 22:06:05 +0100 |
| commit | 5076056e3789467d1412b0312794a747b2ea805f (patch) | |
| tree | 494a4e2c90dde2be5508814f285df248056eb2cf /test | |
| parent | 8e6edcd16040ab635e6490883e47fde7fce56a79 (diff) | |
| download | operum-5076056e3789467d1412b0312794a747b2ea805f.tar.gz operum-5076056e3789467d1412b0312794a747b2ea805f.zip | |
things: added missing tests for the js controller
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/system/things_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
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 |
