diff options
Diffstat (limited to 'test/models/asset_license_test.rb')
| -rw-r--r-- | test/models/asset_license_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/models/asset_license_test.rb b/test/models/asset_license_test.rb new file mode 100644 index 00000000..9f2d04f8 --- /dev/null +++ b/test/models/asset_license_test.rb | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class AssetLicenseTest < ActiveSupport::TestCase | ||
| 4 | test "find returns a populated entry for a known key" do | ||
| 5 | entry = AssetLicense.find("cc_by_4") | ||
| 6 | |||
| 7 | assert_equal "cc_by_4", entry.key | ||
| 8 | assert_equal "https://creativecommons.org/licenses/by/4.0/", entry.url | ||
| 9 | assert entry.requires_attribution | ||
| 10 | assert_equal "license", entry.style | ||
| 11 | end | ||
| 12 | |||
| 13 | test "find returns nil for an unknown or blank key" do | ||
| 14 | assert_nil AssetLicense.find("not_a_real_license") | ||
| 15 | assert_nil AssetLicense.find(nil) | ||
| 16 | assert_nil AssetLicense.find("") | ||
| 17 | end | ||
| 18 | |||
| 19 | test "keys includes every dictionary entry" do | ||
| 20 | assert_includes AssetLicense.keys, "cc0" | ||
| 21 | assert_includes AssetLicense.keys, "own_work" | ||
| 22 | end | ||
| 23 | |||
| 24 | test "a note-style entry has no attribution requirement and no url" do | ||
| 25 | entry = AssetLicense.find("own_work") | ||
| 26 | |||
| 27 | assert_not entry.requires_attribution | ||
| 28 | assert_nil entry.url | ||
| 29 | assert_equal "note", entry.style | ||
| 30 | end | ||
| 31 | end | ||
