Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change check out button text on item page #4865

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/assets/stylesheets/avalon/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ button.close {
text-decoration: none;
}
}

.check-out-btn:hover {
transform:scale(1.1);
-webkit-transform:scale(1.1);
-moz-transform:scale(1.1);
}
17 changes: 2 additions & 15 deletions app/views/media_objects/_checkout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,9 @@ Unless required by applicable law or agreed to in writing, software distributed
--- END LICENSE_HEADER BLOCK ---
%>
<% media_object_id=@media_object.id %>
<% lending_period=ActiveSupport::Duration.build(@media_object.lending_period).to_day_hour_s%>
<%= form_for(Checkout.new) do |f| %>
<%= hidden_field_tag "authenticity_token", form_authenticity_token %>
<%= hidden_field_tag "checkout[media_object_id]", media_object_id %>
<%= f.submit "Check Out", class: "btn btn-info check-out-btn",
data: { lending_period: ActiveSupport::Duration.build(@media_object.lending_period).to_day_hour_s } %>
<% end %>

<% content_for :page_scripts do %>
<script>
$(".check-out-btn").hover(
function() {
var lending_period = $(this).data().lendingPeriod;
$(this).val(`Borrow for ${lending_period}`);
}, function() {
$(this).val('Check Out');
}
);
</script>
<%= f.submit "Borrow for #{lending_period}", class: "btn btn-info" %>
<% end %>
27 changes: 27 additions & 0 deletions spec/features/media_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,31 @@
end
end
end
describe 'displays cdl controls' do
before { allow(Settings.controlled_digital_lending).to receive(:enable).and_return(true) }
let(:available_media_object) { FactoryBot.build(:media_object) }
let!(:mf) { FactoryBot.create(:master_file, media_object: available_media_object) }

context 'displays embedded player' do
it 'with proper text when available' do
visit media_object_path(available_media_object)
expect(page).to have_content('Borrow this item to access media resources.')
expect(page).to have_selector(:link_or_button, 'Borrow for 14 days')
end
it 'with proper text when not available' do
# Checkout the available media object with a different user
normal_user = FactoryBot.create(:user)
FactoryBot.create(:checkout, media_object_id: available_media_object.id, user_id: normal_user.id).save

visit media_object_path(available_media_object)
expect(page.has_content?('This resource is not available to be checked out at the moment. Please check again later.')).to be_truthy
end
end

it 'displays countdown timer when checked out' do
visit media_object_path(media_object)
expect(page.has_content?('Time remaining:')).to be_truthy
expect(page).to have_selector(:link_or_button, 'Return now')
end
end
end