This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
Add gallery image JSON #767
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,18 @@ | ||
# frozen_string_literal: true | ||
class GalleryImagesController < ApplicationController | ||
def show | ||
@gallery = Gallery.find_by_slug(params[:gallery_slug]) | ||
@image = @gallery.images.where(position: params[:position]).first | ||
@response, @document = fetch(@image.europeana_record_id, api_query_params) | ||
|
||
respond_to do |format| | ||
format.json | ||
end | ||
end | ||
|
||
protected | ||
|
||
def api_query_params | ||
params.slice(:api_url) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
presenter = Document::RecordPresenter.new(@document, controller) | ||
|
||
json.description presenter.field_value('proxies.dcDescription') | ||
json.creation_date presenter.field_value('proxies.dcDate') | ||
json.data_provider presenter.field_value('aggregations.edmDataProvider') | ||
json.provider presenter.field_value('aggregations.edmProvider') | ||
json.rights presenter.simple_rights_label_data | ||
json.url_collection search_url(q: %(edm_datasetName:"#{presenter.field_value('edmDatasetName')}")) |
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,31 @@ | ||
# frozen_string_literal: true | ||
RSpec.describe GalleryImagesController do | ||
describe '#show' do | ||
context 'when gallery is published' do | ||
let(:gallery) { Gallery.published.first } | ||
let(:image) { gallery.images.first } | ||
let(:params) { { locale: 'en', gallery_slug: gallery.slug, position: image.position, format: 'json' } } | ||
|
||
it 'returns http success' do | ||
get :show, params | ||
expect(response).to have_http_status(:success) | ||
end | ||
|
||
it 'assigns gallery to @gallery' do | ||
get :show, params | ||
expect(assigns[:gallery]).to eq(gallery) | ||
end | ||
|
||
it 'assigns image to @image' do | ||
get :show, params | ||
expect(assigns[:image]).to eq(image) | ||
end | ||
|
||
it 'requests image metadata from the record API' do | ||
get :show, params | ||
expect(an_api_record_request_for(image.europeana_record_id)). | ||
to have_been_made.at_least_once | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
RSpec.describe 'routes for the gallery images controller' do | ||
it 'routes GET /en/explore/galleries/high-heels/images/2 to gallery_images#show' do | ||
expect(get('/en/explore/galleries/high-heels/images/2')).to route_to('gallery_images#show', locale: 'en', gallery_slug: 'high-heels', position: '2') | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [152/140]