Skip to content

Commit

Permalink
fix for to being off by one
Browse files Browse the repository at this point in the history
  • Loading branch information
dnoneill committed Sep 25, 2024
1 parent 51405c3 commit 30f251d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ jobs:
blacklight_version: "~> 7.0"
experimental: false
additional_name: Rails 6.1, Ruby 3.1
- ruby: "3.1"
rails_version: 6.1.7
blacklight_version: "~> 7.0"
experimental: false
view_component_version: "~> 2.66"
additional_name: "Rails 6.1, Ruby 3.1 / ViewComponent 2"
- ruby: "3.2"
rails_version: "7.0.4"
blacklight_version: "~> 8.0"
Expand All @@ -44,13 +50,19 @@ jobs:
env:
RAILS_VERSION: ${{ matrix.rails_version }}
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Modify Gemfile for ViewComponent version
if: contains(toJSON(matrix), 'view_component_version')
run: |
sed -i 's/gem "view_component".*/gem "view_component", "${{ matrix.view_component_version }}"/' Gemfile
bundle install
- name: Install dependencies with Rails ${{ matrix.rails_version }}
run: bundle install
- name: Run tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ class SlideshowPreviewComponent < Blacklight::DocumentComponent

def initialize(document:, document_counter: nil, **args)
super(document: document, document_counter: document_counter, **args)
@document_counter = document_counter || @counter
# ViewComponent 3, document_counter = 0
# ViewComponent 3, @counter = 1
# ViewComponent 3, COLLECTION_INDEX_OFFSET = 1

# ViewComponent 2, document_counter = 1
# ViewComponent 2, @counter = 1
# ViewComponent 2, COLLECTION_INDEX_OFFSET = 0
@document_counter = document_counter ? document_counter + (COLLECTION_INDEX_OFFSET - 1) : @counter - 1
end

def before_render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
expect(rendered).to have_selector '.thumbnail img[@src="http://example.com/image.jpg"]'
end

it 'renders the correct slide number' do
expect(rendered).to have_css '[data-slide-to=\"5\"][data-bs-slide-to=\"5\"]'
end

context 'when the presenter returns nothing' do
let(:document) { SolrDocument.new(id: 'abc') }

Expand Down

0 comments on commit 30f251d

Please sign in to comment.