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 registering on conference #1220

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RegistrationTypesController < Decidim::Conferences::ApplicationController
helper_method :collection, :conference

def index
raise ActionController::RoutingError, "No registration types for this conference " if registration_types.empty? && current_participatory_space.registrations_enabled.empty?
raise ActionController::RoutingError, "No registration types for this conference " if registration_types.empty? && current_participatory_space.registrations_enabled

enforce_permission_to :list, :registration_types
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Decidim
module Conferences
describe ConferencesController do
describe RegistrationTypesControllerController do
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
describe RegistrationTypesControllerController do
describe ConferencesController do

No need to change the described class

routes { Decidim::Conferences::Engine.routes }

let(:organization) { create(:organization) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

require "spec_helper"

module Decidim
module Conferences
describe RegistrationTypesController do
routes { Decidim::Conferences::Engine.routes }

let(:organization) { create(:organization) }
let!(:conference) do
create(
:conference,
:published,
registrations_enabled:,
organization:
)
end
let(:registrations_enabled) { true }
let(:registration_types_count) { 5 }
let!(:registration_types) do
create_list(:registration_type, registration_types_count, conference:)
end
let(:registration_type) { registration_types.first }
Copy link
Author

Choose a reason for hiding this comment

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

Unused variable registration_type


before do
request.env["decidim.current_organization"] = organization
end

describe "index" do
context "when registration_types is present" do
it "does not raise an error" do
get :index, params: { conference_slug: conference.slug }
assert_response :success
end
end

context "when registration_types is empty" do
let(:registration_types) { nil }
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
let(:registration_types) { nil }
let(:registration_types) { [] }

context "and current_participatory_space registrations is enabled" do
it "does raise an error" do
expect { get :index, params: { conference_slug: conference.slug } }
.to raise_error(ActionController::RoutingError)
end
end

context "and current_participatory_space registrations is disabled" do
let(:registrations_enabled) { false }

it "does not raise an error" do
get :index, params: { conference_slug: conference.slug }
assert_response :success
end
end
end
end
end
end
end
13 changes: 13 additions & 0 deletions decidim-conferences/spec/system/conference_registrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ def visit_conference_registration_type
expect(page).to have_css("button[disabled]", text: "Registration", count: 4)
end
end

context "and there is no registrations types" do
let!(:registration_types) { [] }

it "allows to register" do
visit_conference
within ".conference__hero" do
expect(page).to have_content "Register"
click_on "Register"
expect(page).to have_content "CHOOSE YOUR REGISTRATION OPTION:"
end
end
end
end

context "and the user is going to the conference" do
Expand Down
Loading