New meeting and meeting copy refinements.

* the meeting or copy author gets automagically added as an invitee. myproject #2670
* better test coverage of the meeting copy
* corrected lost initial comment for copied agendas in meeting copy (introduced in commit:5e8a2b54)
* restore copying the agenda on meeting copy lost in commit:48062434
* test and account for freak boundary conditions introduced by the better copy feature (also see myproject #3109)
pull/6827/head
Felix Schäfer 14 years ago committed by Felix Schäfer
parent 307bf96946
commit 21abdbbcce
  1. 4
      app/controllers/meetings_controller.rb
  2. 9
      app/models/meeting.rb
  3. 2
      app/models/meeting_content.rb
  4. 44
      features/meetings_copy.feature
  5. 10
      features/meetings_new.feature
  6. 14
      features/step_definitions/meeting_steps.rb

@ -21,6 +21,7 @@ class MeetingsController < ApplicationController
end
def create
@meeting.participants.clear # Start with a clean set of participants
@meeting.attributes = params[:meeting]
begin
if (agenda = Meeting.find(params[:copy_from_id]).agenda).present?
@ -42,7 +43,8 @@ class MeetingsController < ApplicationController
end
def copy
@meeting = @meeting.copy
params[:copy_from_id] = @meeting.id
@meeting = @meeting.copy(:author => User.current, :start_time => nil)
render :action => 'new', :project_id => @project
end

@ -64,10 +64,12 @@ class Meeting < ActiveRecord::Base
agenda.text if agenda.present?
end
def copy
def copy(attrs)
copy = self.clone
copy.start_time = Date.tomorrow + 10.hours
copy.participants = self.participants.invited.collect(&:clone).each{|p| p.attended=false} # Make sure the participants have no id
copy.attributes = attrs
copy.send(:after_initialize)
copy_participant_user_ids = copy.participants.collect(&:user_id)
copy.participants << self.participants.invited.reject{|p| copy_participant_user_ids.include? p.user_id}.collect(&:clone).each{|p| p.attended=false} # Make sure the participants have no id
copy
end
@ -77,6 +79,7 @@ class Meeting < ActiveRecord::Base
# set defaults
self.start_time ||= Date.tomorrow + 10.hours
self.duration ||= 1
self.participants.build(:user => self.author, :invited => true) if (self.new_record? && self.participants.empty? && self.author) # Don't add the author as participant if we already have some through nested attributes
end
private

@ -32,7 +32,7 @@ class MeetingContent < ActiveRecord::Base
protected
def after_initialize
self.comment = nil
self.comment = nil unless self.new_record? # Don't reset the comment if we haven't been saved with it yet
end
class Version

@ -9,6 +9,8 @@ Feature: Copy meetings
And there is 1 user with:
| login | alice |
| language | en |
| firstname | Alice |
| lastname | Alice |
And there is 1 user with:
| login | bob |
And there is 1 user with:
@ -46,3 +48,45 @@ Feature: Copy meetings
And the "meeting[duration]" field should contain "1.5"
#And no participant should be selected as attendee
#And only invited participants should be selected as invitees
@javascript
Scenario: Navigate to a meeting copy page to make sure the author is selected as invited but not as attendee
Given the role "user" may have the following rights:
| view_meetings |
| create_meetings |
And "alice" attended the Meeting "Alices Meeting"
When I login as "alice"
And I go to the Meetings page for the project called "dingens"
And I click on "Alices Meeting"
And I click on "Copy"
Then the "meeting[participants_attributes][][invited]" checkbox should be checked
And the "meeting[participants_attributes][][attended]" checkbox should not be checked
@javascript
Scenario: Copy a meeting and make sure the author isn''t copied over
Given the role "user" may have the following rights:
| view_meetings |
| create_meetings |
When I login as "alice"
And I go to the Meetings page for the project called "dingens"
And I click on "Alices Meeting"
And I click on "Copy"
And I click on "Create"
Then I should not see "Alice Alice; Alice Alice"
And I should see "Alice Alice"
@javascript
Scenario: Copy a meeting and make sure the agenda ist copied over
Given the role "user" may have the following rights:
| view_meetings |
| create_meetings |
And the meeting "Alices Meeting" has 1 agenda with:
| text | "blubber" |
When I login as "alice"
And I go to the Meetings page for the project called "dingens"
And I click on "Alices Meeting"
And I click on "Copy"
And I click on "Create"
And I click on "Agenda"
And I click on "History"
Then I should see "Copied from Meeting #"

@ -73,3 +73,13 @@ Feature: Create new meetings
#And "05" should be selectable from "meeting_start_time_5i"
And I should see "00" within "#meeting_start_time_5i"
And I should see "05" within "#meeting_start_time_5i"
@javascript
Scenario: Visit the new meeting page to make sure the author is selected as invited
Given the role "user" may have the following rights:
| view_meetings |
| create_meetings |
When I login as "alice"
And I go to the Meetings page for the project called "dingens"
And I click on "New Meeting"
Then the "meeting[participants_attributes][][invited]" checkbox should be checked

@ -16,3 +16,17 @@ Given /^the [Mm]eeting "(.+)" has minutes with:$/ do |meeting,table|
m.minutes = Factory.build(:meeting_minutes)
send_table_to_object(m.minutes, table)
end
Given /^"(.+)" is invited to the [Mm]eeting "(.+)"$/ do |user,meeting|
m = Meeting.find_by_title(meeting)
p = m.participants.detect{|p| p.user_id = User.find_by_login(user).id} || Factory.build(:meeting_participant, :meeting => m)
p.invited = true
p.save
end
Given /^"(.+)" attended the [Mm]eeting "(.+)"$/ do |user,meeting|
m = Meeting.find_by_title(meeting)
p = m.participants.detect{|p| p.user_id = User.find_by_login(user).id} || Factory.build(:meeting_participant, :meeting => m)
p.attended = true
p.save
end
Loading…
Cancel
Save