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

Fix profiles controller index #1350

Merged
merged 6 commits into from
Feb 22, 2024
Merged

Fix profiles controller index #1350

merged 6 commits into from
Feb 22, 2024

Conversation

tyranja
Copy link
Member

@tyranja tyranja commented Feb 6, 2024

In the index profile view we show all profiles randomize and paginated which leads to showing profiles twice or even more on different pages. This fixes this.

https://speakerinnen.org/en/profiles

Copy link
Member

@sabrina-ulbrich sabrina-ulbrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Only 2 questions

app/controllers/profiles_controller.rb Show resolved Hide resolved
spec/controllers/profiles_controller_spec.rb Outdated Show resolved Hide resolved
Copy link
Member

@zaziemo zaziemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work :) Only some suggestions for better descriptions for describe blocks (as defined in https://www.betterspecs.org/).
Also: everything seems to work, I don' yet understand how one spec works (see comment).

@@ -180,7 +180,7 @@
# Overflow extra: Allow for easy handling of overflowing pages
# See https://ddnexus.github.io/pagy/docs/extras/overflow
require 'pagy/extras/overflow'
Pagy::DEFAULT[:overflow] = :last_page # (other options: :empty_page and :exception)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, diese Änderung habe ich ja schon gemacht. Wäre besser, du rebased auf Master. Ich hatte dort `:last_page noch als Option in den Kommentar geschrieben.

expect(assigns(:aggs_states)).to eq nil
end
end
context 'single profile tests' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich finde den Kontext hier unpassend. Es handelt sich ja nicht nur um Tests mit "single profile". Kann einfach weg.

it 'is not permitted for unauthorized not signed in profile' do
get :show, params: { id: profile_unpublished.id }
expect(response).to redirect_to("/#{I18n.locale}/profiles")
describe 'test index action' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe '#index' do

it 'should be seen by all profiles' do
get :show, params: { id: profile_published.id }
expect(response).to render_template(:show)
describe 'category id search' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe '#search_with_category_id' do


it 'renders edit view' do
expect(response).to render_template(:edit)
describe 'tag filter search' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe '#search_with_tags' do


describe 'update profile action' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe '#update' do

sign_in ada
put :update, params: { id: ada.id, profile: { email: ' ' } }
end
context 'when invalid params are supplied' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context 'with invalid params' do


describe 'update profile action' do
context 'when updating own profile with valid params' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context 'with valid params' do


describe 'destroy profile action' do
describe 'destroy profile action' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe '#destroy' do

get :index, params: { page: 2 }
expect(assigns(:records).count).to eq 2
profiles_page_2 = assigns(:records)
expect(profiles_page_2 & profiles_page_1).to eq []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sieht elegant aus, aber eigentlich verstehe ich nicht genau, was & hier macht. Ist das sowas wie eine Schnittmenge?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jep it checks for an intersection. I wanted to check that we shall no profile twice.

Copy link
Member

@zaziemo zaziemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@zaziemo zaziemo merged commit d0275ac into master Feb 22, 2024
1 check passed
@zaziemo zaziemo deleted the fix-profiles-controller-index branch February 22, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants