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

Conference registering change requests #1222

Merged
Show file tree
Hide file tree
Changes from 3 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: 6 additions & 0 deletions decidim-conferences/app/models/decidim/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def has_available_slots?
available_slots > conference_registrations.count
end

def has_published_registration_types?
return false if registration_types.empty?

registration_types.any?(&:published_at?)
end

def remaining_slots
available_slots - conference_registrations.count
end
Expand Down
28 changes: 28 additions & 0 deletions decidim-conferences/spec/models/decidim/conference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,33 @@ module Decidim

it { is_expected.to be_valid }
end

describe "#has_published_registration_types?" do
context "when conference has no registration type" do
it "returns false" do
expect(conference).not_to have_published_registration_types
end
end

context "when conference has registration types" do
let!(:registration_types) do
create_list(:registration_type, 5, conference:)
end

it "return true" do
expect(conference).to have_published_registration_types
end

context "and the registration types are unpublished" do
let!(:registration_types) do
create_list(:registration_type, 5, :unpublished, conference:)
end

it "returns false" do
expect(conference).not_to have_published_registration_types
end
end
end
end
end
end
Loading