Skip to content

Commit

Permalink
Fix tests to require locale
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed May 16, 2018
1 parent 450918a commit 2c6d4ee
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/jobs/content_restored_version_event_job.rb
Expand Up @@ -8,6 +8,6 @@ def perform(file_set, depositor, revision_id)
end

def action
"User #{link_to_profile depositor} has restored a version '#{revision_id}' of #{link_to repo_object.title.first, Rails.application.routes.url_helpers.hyrax_file_set_path(repo_object)}"
"User #{link_to_profile depositor} has restored a version '#{revision_id}' of #{link_to repo_object.title.first, Rails.application.routes.url_helpers.hyrax_file_set_path(repo_object, locale: I18n.locale)}"
end
end
2 changes: 1 addition & 1 deletion spec/jobs/content_delete_event_job_spec.rb
Expand Up @@ -3,7 +3,7 @@
let(:mock_time) { Time.zone.at(1) }
let(:event) do
{
action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has deleted object '#{curation_concern.id}'",
action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> has deleted object '#{curation_concern.id}'",
timestamp: '1'
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_deposit_event_job_spec.rb
Expand Up @@ -4,7 +4,7 @@
let(:curation_concern) { create(:work, title: ['MacBeth'], user: user) }
let(:event) do
{
action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has deposited <a href=\"/concern/generic_works/#{curation_concern.id}\">MacBeth</a>",
action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> has deposited <a href=\"/concern/generic_works/#{curation_concern.id}\">MacBeth</a>",
timestamp: '1'
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/jobs/content_depositor_change_event_job_spec.rb
Expand Up @@ -4,9 +4,9 @@
let(:generic_work) { create(:generic_work, title: ['BethsMac'], user: user) }
let(:mock_time) { Time.zone.at(1) }
let(:event) do
{ action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> " \
{ action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> " \
"has transferred <a href=\"/concern/generic_works/#{generic_work.id}\">BethsMac</a> " \
"to user <a href=\"/users/#{another_user.to_param}\">#{another_user.user_key}</a>",
"to user <a href=\"/users/#{another_user.to_param}?locale=en\">#{another_user.user_key}</a>",
timestamp: '1' }
end

Expand Down
4 changes: 3 additions & 1 deletion spec/jobs/content_new_version_event_job_spec.rb
Expand Up @@ -3,7 +3,9 @@
let(:file_set) { create(:file_set, title: ['Hamlet'], user: user) }
let(:generic_work) { create(:generic_work, title: ['BethsMac'], user: user) }
let(:mock_time) { Time.zone.at(1) }
let(:event) { { action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has added a new version of <a href=\"/concern/file_sets/#{file_set.id}\">Hamlet</a>", timestamp: '1' } }
let(:event) do
{ action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> has added a new version of <a href=\"/concern/file_sets/#{file_set.id}\">Hamlet</a>", timestamp: '1' }
end

before do
allow(Time).to receive(:now).at_least(:once).and_return(mock_time)
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_restored_version_event_job_spec.rb
Expand Up @@ -4,7 +4,7 @@
let(:generic_work) { create(:generic_work, title: ['BethsMac'], user: user) }
let(:mock_time) { Time.zone.at(1) }
let(:event) do
{ action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> " \
{ action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> " \
"has restored a version 'content.0' of " \
"<a href=\"/concern/file_sets/#{file_set.id}\">Hamlet</a>",
timestamp: '1' }
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/content_update_event_job_spec.rb
Expand Up @@ -4,7 +4,7 @@
let(:curation_concern) { create(:file_set, title: ['Hamlet'], user: user) }
let(:event) do
{
action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has updated <a href=\"/concern/file_sets/#{curation_concern.id}\">Hamlet</a>",
action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> has updated <a href=\"/concern/file_sets/#{curation_concern.id}\">Hamlet</a>",
timestamp: '1'
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/file_set_attached_event_job_spec.rb
Expand Up @@ -12,7 +12,7 @@
let(:curation_concern) { create(:work_with_one_file, title: ['MacBeth'], user: user) }
let(:event) do
{
action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> " \
action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> " \
"has attached <a href=\"/concern/file_sets/#{file_set.id}\">A Contained FileSet</a> " \
"to <a href=\"/concern/generic_works/#{curation_concern.id}\">MacBeth</a>",
timestamp: '1'
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/user_edit_profile_event_job_spec.rb
@@ -1,7 +1,7 @@
RSpec.describe UserEditProfileEventJob do
let(:user) { create(:user) }
let(:mock_time) { Time.zone.at(1) }
let(:event) { { action: "User <a href=\"/users/#{user.to_param}\">#{user.user_key}</a> has edited their profile", timestamp: '1' } }
let(:event) { { action: "User <a href=\"/users/#{user.to_param}?locale=en\">#{user.user_key}</a> has edited their profile", timestamp: '1' } }

before do
allow(Time).to receive(:now).at_least(:once).and_return(mock_time)
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/hyrax/admin_set_presenter_spec.rb
Expand Up @@ -68,7 +68,7 @@

subject { presenter.show_path }

it { is_expected.to eq "/admin/admin_sets/#{admin_set.id}" }
it { is_expected.to eq "/admin/admin_sets/#{admin_set.id}?locale=en" }
end

describe '#managed_access' do
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/hyrax/collection_presenter_spec.rb
Expand Up @@ -357,7 +357,7 @@
describe '#show_path' do
subject { presenter.show_path }

it { is_expected.to eq "/dashboard/collections/#{solr_doc.id}" }
it { is_expected.to eq "/dashboard/collections/#{solr_doc.id}?locale=en" }
end

describe "banner_file" do
Expand Down
Expand Up @@ -11,8 +11,8 @@
%(
<tr><th>Name</th>
<td><ul class='tabular'>
<li class="attribute attribute-name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Bob">Bob</a></li>
<li class="attribute attribute-name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Jessica">Jessica</a></li>
<li class="attribute attribute-name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Bob&locale=en">Bob</a></li>
<li class="attribute attribute-name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Jessica&locale=en">Jessica</a></li>
</ul></td></tr>
)
end
Expand All @@ -28,7 +28,7 @@
let(:rendered_link_query) { URI.parse(rendered_link['href']).query }

it "escapes content properly" do
expect(rendered_link_query).to eq "#{CGI.escape('f[name_sim][]')}=#{CGI.escape('John & Bob')}"
expect(rendered_link_query).to eq "#{CGI.escape('f[name_sim][]')}=#{CGI.escape('John & Bob')}&locale=en"
end
end
end
Expand Down
Expand Up @@ -10,8 +10,8 @@
let(:tr_content) do
"<tr><th>Name</th>\n" \
"<td><ul class='tabular'>" \
"<li class=\"attribute attribute-name\"><a href=\"/catalog?q=Bob&amp;search_field=name\">Bob</a></li>\n" \
"<li class=\"attribute attribute-name\"><a href=\"/catalog?q=Jessica&amp;search_field=name\">Jessica</a></li>\n" \
"<li class=\"attribute attribute-name\"><a href=\"/catalog?locale=en&q=Bob&amp;search_field=name\">Bob</a></li>\n" \
"<li class=\"attribute attribute-name\"><a href=\"/catalog?locale=en&q=Jessica&amp;search_field=name\">Jessica</a></li>\n" \
"</ul></td></tr>"
end

Expand Down
Expand Up @@ -45,7 +45,7 @@ def check_tr_data_attributes
expect(rendered).to have_selector("tr#document_#{id}")
check_tr_data_attributes
expect(rendered).to have_selector("tr[data-post-delete-url='/dashboard/collections/#{id}']")
expect(rendered).to have_link 'Collection Title', href: hyrax.dashboard_collection_path(id)
expect(rendered).to have_link 'Collection Title', href: hyrax.dashboard_collection_path(id, locale: I18n.locale)
expect(rendered).to have_link 'Edit collection', href: hyrax.edit_dashboard_collection_path(id)
expect(rendered).to have_link 'Delete collection'
expect(rendered).to have_link 'Add to collection'
Expand Down

0 comments on commit 2c6d4ee

Please sign in to comment.