-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef769ef
commit d21e3e5
Showing
14 changed files
with
140 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'validates_automatically' | ||
|
||
class SpecialDomain < ApplicationRecord | ||
include ValidatesAutomatically | ||
|
||
validates :domain_name, presence: true | ||
|
||
def why_special_enum | ||
[ | ||
['Full urls only for researchers', :full_urls_only_for_researchers] | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateSpecialDomains < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :special_domains do |t| | ||
t.string :domain_name | ||
t.text :notes | ||
t.jsonb :why_special | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,7 +222,63 @@ | |
expect(page).to have_content('You are not allowed to download this document.') | ||
end | ||
end | ||
|
||
|
||
context 'special domains' do | ||
scenario 'full_urls_only_for_researchers filter' do | ||
notice = build(:dmca) | ||
notice.works << Work.new( | ||
description: 'lol', | ||
infringing_urls: [ | ||
InfringingUrl.new(url: 'https://this-domain-is-so-special.com/hey-buddy/1122'), | ||
InfringingUrl.new(url: 'https://not-so-special.com/hey-hey/1122') | ||
] | ||
) | ||
notice.save! | ||
|
||
SpecialDomain.create!( | ||
domain_name: '%this-domain-is-so-special.com%', | ||
why_special: ['full_urls_only_for_researchers'] | ||
) | ||
|
||
token_url = TokenUrl.create( | ||
email: '[email protected]', | ||
notice: notice, | ||
expiration_date: Time.now + LumenSetting.get_i('truncation_token_urls_active_period').seconds | ||
) | ||
|
||
visit notice_url(notice, access_token: token_url.token) | ||
|
||
expect(page).to have_content('https://not-so-special.com/hey-hey/1122') | ||
expect(page).to have_content('this-domain-is-so-special.com') | ||
expect(page).not_to have_content('https://this-domain-is-so-special.com/hey-buddy/1122') | ||
|
||
user = create(:user, :super_admin) | ||
sign_in(user) | ||
|
||
visit notice_url(notice) | ||
|
||
expect(page).to have_content('https://not-so-special.com/hey-hey/1122') | ||
expect(page).to have_content('https://this-domain-is-so-special.com/hey-buddy/1122') | ||
|
||
sign_out | ||
|
||
user = create(:user, :researcher) | ||
sign_in(user) | ||
|
||
visit notice_url(notice) | ||
|
||
expect(page).to have_content('https://not-so-special.com/hey-hey/1122') | ||
expect(page).to have_content('https://this-domain-is-so-special.com/hey-buddy/1122') | ||
|
||
sign_out | ||
|
||
visit notice_url(notice) | ||
|
||
expect(page).not_to have_content('https://not-so-special.com/hey-hey/1122') | ||
expect(page).not_to have_content('https://this-domain-is-so-special.com/hey-buddy/1122') | ||
end | ||
end | ||
|
||
def check_full_works_urls | ||
within('#works') do | ||
expect(page).to have_content 'http://www.example.com/original_work.pdf' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters