mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Enable Style/IndentationWidth cop
The offenses were fixed manually
This commit is contained in:
parent
e3b51dfc2b
commit
9c58397cd2
6 changed files with 71 additions and 83 deletions
|
|
@ -469,17 +469,6 @@ Style/IndentationConsistency:
|
|||
- 'app/models/event.rb'
|
||||
- 'spec/controllers/subscriptions_controller_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Width, IgnoredPatterns.
|
||||
Style/IndentationWidth:
|
||||
Exclude:
|
||||
- 'app/helpers/format_helper.rb'
|
||||
- 'app/serializers/conference_serializer.rb'
|
||||
- 'db/migrate/20140701123203_add_events_per_week_to_conference.rb'
|
||||
- 'lib/tasks/demo_data_for_development.rake'
|
||||
- 'spec/models/ability_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/LeadingCommentSpace:
|
||||
|
|
|
|||
|
|
@ -102,13 +102,12 @@ module FormatHelper
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/EndAlignment
|
||||
def word_pluralize(count, singular, plural = nil)
|
||||
word = if (count == 1 || count =~ /^1(\.0+)?$/)
|
||||
singular
|
||||
else
|
||||
plural || singular.pluralize
|
||||
end
|
||||
singular
|
||||
else
|
||||
plural || singular.pluralize
|
||||
end
|
||||
|
||||
"#{word}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
|
||||
def date_range
|
||||
if defined? date_string(object.start_date, object.end_date)
|
||||
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
|
||||
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,50 +22,50 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
|
|||
if event
|
||||
conference = TempConference.find_by_id(event.conference_id)
|
||||
if conference
|
||||
week = event_version.created_at.end_of_week
|
||||
week = event_version.created_at.end_of_week
|
||||
|
||||
no_events = {
|
||||
new: 0,
|
||||
withdrawn: 0,
|
||||
unconfirmed: 0,
|
||||
confirmed: 0,
|
||||
canceled: 0,
|
||||
rejected: 0,
|
||||
}
|
||||
|
||||
if !conference.events_per_week
|
||||
conference.events_per_week = {
|
||||
week => no_events
|
||||
no_events = {
|
||||
new: 0,
|
||||
withdrawn: 0,
|
||||
unconfirmed: 0,
|
||||
confirmed: 0,
|
||||
canceled: 0,
|
||||
rejected: 0,
|
||||
}
|
||||
elsif !conference.events_per_week[week]
|
||||
conference.events_per_week[week] = no_events
|
||||
end
|
||||
|
||||
if event_version.object_changes &&
|
||||
event_version.event == 'create'
|
||||
|
||||
# Increment the new state
|
||||
conference.events_per_week[week][:new] += 1
|
||||
elsif event_version.object_changes &&
|
||||
event_version.object_changes[:state]
|
||||
|
||||
prev_state = event_version.object_changes[:state][0].to_sym
|
||||
next_state = event_version.object_changes[:state][1].to_sym
|
||||
|
||||
# Backward compatibility: deprecated state :review now :new
|
||||
if prev_state == :review
|
||||
prev_state = :new
|
||||
elsif next_state == :review
|
||||
next_state = :new
|
||||
if !conference.events_per_week
|
||||
conference.events_per_week = {
|
||||
week => no_events
|
||||
}
|
||||
elsif !conference.events_per_week[week]
|
||||
conference.events_per_week[week] = no_events
|
||||
end
|
||||
|
||||
# Increment the next state
|
||||
conference.events_per_week[week][next_state] += 1
|
||||
if event_version.object_changes &&
|
||||
event_version.event == 'create'
|
||||
|
||||
# Decrement the previous state
|
||||
conference.events_per_week[week][prev_state] -= 1
|
||||
end
|
||||
conference.save
|
||||
# Increment the new state
|
||||
conference.events_per_week[week][:new] += 1
|
||||
elsif event_version.object_changes &&
|
||||
event_version.object_changes[:state]
|
||||
|
||||
prev_state = event_version.object_changes[:state][0].to_sym
|
||||
next_state = event_version.object_changes[:state][1].to_sym
|
||||
|
||||
# Backward compatibility: deprecated state :review now :new
|
||||
if prev_state == :review
|
||||
prev_state = :new
|
||||
elsif next_state == :review
|
||||
next_state = :new
|
||||
end
|
||||
|
||||
# Increment the next state
|
||||
conference.events_per_week[week][next_state] += 1
|
||||
|
||||
# Decrement the previous state
|
||||
conference.events_per_week[week][prev_state] -= 1
|
||||
end
|
||||
conference.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,37 +4,37 @@ namespace :data do
|
|||
include FactoryGirl::Syntax::Methods
|
||||
|
||||
def generate_program conference
|
||||
program = conference.program
|
||||
user1 = create(:user)
|
||||
user2 = create(:user)
|
||||
program = conference.program
|
||||
user1 = create(:user)
|
||||
user2 = create(:user)
|
||||
|
||||
conference_rooms = conference.venue.rooms
|
||||
conference_rooms = conference.venue.rooms
|
||||
|
||||
selected_schedule = create(:schedule, program: program)
|
||||
demo_schedule = create(:schedule, program: program)
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
selected_schedule = create(:schedule, program: program)
|
||||
demo_schedule = create(:schedule, program: program)
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
|
||||
create(:event, program: program, title: 'Demo Event', abstract: 'This is a demo event instance whose state not defined.')
|
||||
create(:event, program: program, title: 'Demo Rejected Event', state: 'rejected', abstract: 'This is demo event instance in a rejected state.')
|
||||
create(:event, program: program, title: 'Demo Unconfirmed Event', state: 'unconfirmed', abstract: 'This is a demo event instance in unconfirmed state.')
|
||||
create(:event, program: program, title: 'Demo Confirmed Unscheduled Event', state: 'confirmed', abstract: 'This is a demo event instance in a confirmed state.')
|
||||
create(:event, program: program, title: 'Demo Event', abstract: 'This is a demo event instance whose state not defined.')
|
||||
create(:event, program: program, title: 'Demo Rejected Event', state: 'rejected', abstract: 'This is demo event instance in a rejected state.')
|
||||
create(:event, program: program, title: 'Demo Unconfirmed Event', state: 'unconfirmed', abstract: 'This is a demo event instance in unconfirmed state.')
|
||||
create(:event, program: program, title: 'Demo Confirmed Unscheduled Event', state: 'confirmed', abstract: 'This is a demo event instance in a confirmed state.')
|
||||
|
||||
first_scheduled_event = create(:event, program: program, title: 'first_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
|
||||
second_scheduled_event = create(:event, program: program, title: 'second_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
|
||||
multiple_speaker_event = create(:event, program: program, title: 'multiple_speaker_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance having multiple speakers.')
|
||||
first_scheduled_event = create(:event, program: program, title: 'first_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
|
||||
second_scheduled_event = create(:event, program: program, title: 'second_scheduled_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance.')
|
||||
multiple_speaker_event = create(:event, program: program, title: 'multiple_speaker_event', state: 'confirmed', abstract: 'This is a demo scheduled event instance having multiple speakers.')
|
||||
|
||||
create(:event_user, event: multiple_speaker_event, user: user1, event_role: 'speaker')
|
||||
create(:event_user, event: multiple_speaker_event, user: user2, event_role: 'speaker')
|
||||
create(:event_user, event: multiple_speaker_event, user: user1, event_role: 'speaker')
|
||||
create(:event_user, event: multiple_speaker_event, user: user2, event_role: 'speaker')
|
||||
|
||||
create(:event_schedule, event: first_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
|
||||
create(:event_schedule, event: second_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.second)
|
||||
create(:event_schedule, event: multiple_speaker_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: first_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: second_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: multiple_speaker_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
|
||||
create(:event_schedule, event: first_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
|
||||
create(:event_schedule, event: second_scheduled_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.second)
|
||||
create(:event_schedule, event: multiple_speaker_event, schedule: selected_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: first_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 15.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: second_scheduled_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours + 30.minutes, room: conference_rooms.third)
|
||||
create(:event_schedule, event: multiple_speaker_event, schedule: demo_schedule, start_time: conference.start_date + conference.start_hour.hours, room: conference_rooms.first)
|
||||
|
||||
create(:registration, user: user1, conference: conference)
|
||||
create(:registration, user: user2, conference: conference)
|
||||
create(:registration, user: user1, conference: conference)
|
||||
create(:registration, user: user2, conference: conference)
|
||||
end
|
||||
|
||||
# This is a full conference demo instance that will happen in the future.
|
||||
|
|
@ -73,5 +73,5 @@ namespace :data do
|
|||
# Registration for this conference has reached its limit.
|
||||
conference = create(:full_conference, title: 'Zypper Docker Conference', short_title: 'zypper', registration_limit: 2, start_date: 3.days.from_now, end_date: 7.days.from_now, start_hour: 7, end_hour: 19, description: 'This is a full conference demo instance. Its registrations has reached the limit.')
|
||||
generate_program conference
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ describe 'User' do
|
|||
it{ should_not be_able_to(:show, conference_not_public)}
|
||||
|
||||
it do
|
||||
conference_public.program.schedule_public = true
|
||||
conference_public.program.save
|
||||
should be_able_to(:schedule, conference_public)
|
||||
conference_public.program.schedule_public = true
|
||||
conference_public.program.save
|
||||
should be_able_to(:schedule, conference_public)
|
||||
end
|
||||
it{ should_not be_able_to(:schedule, conference_not_public)}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue