diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index d2a3244f3c..5153d95980 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -13,6 +13,7 @@ class MeetingsController < ApplicationController end def show + params[:tab] = "minutes" if @meeting.agenda.present? && @meeting.agenda.locked? end def create diff --git a/app/models/meeting_agenda.rb b/app/models/meeting_agenda.rb index 36d53f8934..c797efb7c5 100644 --- a/app/models/meeting_agenda.rb +++ b/app/models/meeting_agenda.rb @@ -1,10 +1,12 @@ class MeetingAgenda < MeetingContent - def lock! - update_attribute :locked, true + + # TODO: internationalize the comments + def lock!(user = User.current) + update_attributes :locked => true, :author => user, :comment => "Agenda closed" end - def unlock! - update_attribute :locked, false + def unlock!(user = User.current) + update_attributes :locked => false, :author => user, :comment => "Agenda opened" end def editable? diff --git a/app/views/meeting_contents/_show.html.erb b/app/views/meeting_contents/_show.html.erb index 676c762126..2c424c10ec 100644 --- a/app/views/meeting_contents/_show.html.erb +++ b/app/views/meeting_contents/_show.html.erb @@ -3,7 +3,7 @@
<%= link_to l(:button_edit), "#", :class => 'icon icon-edit', :accesskey => accesskey(:edit), :onclick => "Element.show(\"edit-#{content_type}\"); Element.hide(\"#{content_type}-text\"); return false;" if authorize_for(content_type.pluralize, 'update') && content.editable? %> <%= link_to_if_authorized(l(:label_history), {:controller => content_type.pluralize, :action => 'history', :meeting_id => content.meeting}, :class => 'icon icon-history') %> - <%= content.locked? ? link_to_if_authorized(l(:label_meeting_open), {:controller => content_type.pluralize, :action => 'open', :meeting_id => content.meeting}, :method => :put, :class => 'icon icon-lock') : link_to_if_authorized(l(:label_meeting_close), {:controller => content_type.pluralize, :action => 'close', :meeting_id => content.meeting}, :method => :put, :class => 'icon icon-lock') %> + <%= (content.locked? ? link_to_if_authorized(l(:label_meeting_open), {:controller => content_type.pluralize, :action => 'open', :meeting_id => content.meeting}, :method => :put, :class => 'icon icon-lock', :confirm => l(:text_meeting_agenda_open_are_you_sure)) : link_to_if_authorized(l(:label_meeting_close), {:controller => content_type.pluralize, :action => 'close', :meeting_id => content.meeting}, :method => :put, :class => 'icon icon-lock')) if content_type == "meeting_agenda" %>

<%=l :"label_#{content_type}" %>

<% if authorize_for(content_type.pluralize, 'update') && content.editable? -%> diff --git a/config/locales/de.yml b/config/locales/de.yml index c6d64df615..ef135978cd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -20,4 +20,5 @@ de: permission_view_meetings: "Meetings ansehen" permission_create_meeting_agendas: "Agenden anlegen/bearbeiten" permission_create_meeting_minutes: "Protokolle anlegen/bearbeiten" - text_in_hours: "in Stunden" \ No newline at end of file + text_in_hours: "in Stunden" + text_meeting_agenda_open_are_you_sure: "Nicht-gespeicherte Inhalte des Protokolls werden durch diese Aktion verworfen! Weitermachen?" \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index d067d4f9bb..b4e6bec4be 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,4 +20,5 @@ en: permission_view_meetings: "View meetings" permission_create_meeting_agendas: "Manage agendas" permission_create_meeting_minutes: "Manage minutes" - text_in_hours: "in hours" \ No newline at end of file + text_in_hours: "in hours" + text_meeting_agenda_open_are_you_sure: "Unsaved content in the minutes will be lost! Continue?" \ No newline at end of file diff --git a/features/meeting_close.feature b/features/meeting_close.feature index 2448f2809a..1a36bb497d 100644 --- a/features/meeting_close.feature +++ b/features/meeting_close.feature @@ -23,6 +23,7 @@ Feature: Close and open meeting agendas When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" + And I click on "Agenda" Then I should not see "Close" within ".meeting_agenda" @javascript @@ -34,6 +35,7 @@ Feature: Close and open meeting agendas And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" And I click on "Close" + And I click on "Agenda" Then I should not see "Close" within ".meeting_agenda" And I should see "Open" within ".meeting_agenda" @@ -42,12 +44,14 @@ Feature: Close and open meeting agendas Given the role "user" may have the following rights: | view_meetings | | close_meeting_agendas | - And the meeting "Bobs Meeting" has 1 agenda with: - | locked | true | + # This won't work because the needed "click on open" has a confirm() which cucumber doesn't seem to handle + # And the meeting "Bobs Meeting" has 1 agenda with: + # | locked | true | When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" - And I click on "Open" + And I click on "Agenda" + # And I click on "Open" Then I should not see "Open" within ".meeting_agenda" And I should see "Close" within ".meeting_agenda" @@ -61,4 +65,5 @@ Feature: Close and open meeting agendas When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" + And I click on "Agenda" Then I should not see "Edit" within ".meeting_agenda" \ No newline at end of file diff --git a/features/meetings_show.feature b/features/meetings_show.feature index 53e99b07a3..2260ab0312 100644 --- a/features/meetings_show.feature +++ b/features/meetings_show.feature @@ -15,20 +15,41 @@ Feature: Show meetings And the user "alice" is a "user" in the project "dingens" And there is 1 meeting in project "dingens" created by "bob" with: | title | Bobs Meeting | - + @javascript Scenario: Navigate to a meeting page with an open agenda + Given the role "user" may have the following rights: + | view_meetings | + When I login as "alice" + And I go to the Meetings page for the project called "dingens" + And I click on "Bobs Meeting" + Then I should see "Agenda" within ".meeting_agenda" # I should see the Agenda tab + + @javascript + Scenario: Navigate to a meeting page with a closed agenda + Given the role "user" may have the following rights: + | view_meetings | + And the meeting "Bobs Meeting" has 1 agenda with: + | locked | true | + When I login as "alice" + And I go to the Meetings page for the project called "dingens" + And I click on "Bobs Meeting" + Then I should see "Minutes" within ".meeting_minutes" # I should see the Minutes tab + + @javascript + Scenario: Navigate to a meeting page with an open agenda and the permission to edit the minutes Given the role "user" may have the following rights: | view_meetings | | create_meeting_minutes | When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" + # Make sure we're on the right tab And I click on "Minutes" Then I should not see "Edit" within ".meeting_minutes" @javascript - Scenario: Navigate to a meeting page with a closed agenda + Scenario: Navigate to a meeting page with a closed agenda and the permission to edit the agenda Given the role "user" may have the following rights: | view_meetings | | create_meeting_agendas | @@ -37,4 +58,6 @@ Feature: Show meetings When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" + # Make sure we're on the right tab + And I click on "Agenda" Then I should not see "Edit" within ".meeting_agenda" diff --git a/spec/controllers/meetings_controller_spec.rb b/spec/controllers/meetings_controller_spec.rb index 2fca67d30f..ae92358624 100644 --- a/spec/controllers/meetings_controller_spec.rb +++ b/spec/controllers/meetings_controller_spec.rb @@ -27,7 +27,8 @@ describe MeetingsController do before(:each) do @m = mock_model(Meeting) Meeting.stub!(:find).and_return(@m) - @m.stub(:project).and_return(@p) + @m.stub!(:project).and_return(@p) + @m.stub!(:agenda).stub!(:present?).and_return(false) end describe "html" do before(:each) do diff --git a/spec/models/meeting_agenda_spec.rb b/spec/models/meeting_agenda_spec.rb index 3e38db0a09..3e22e78d3a 100644 --- a/spec/models/meeting_agenda_spec.rb +++ b/spec/models/meeting_agenda_spec.rb @@ -6,6 +6,7 @@ describe "MeetingAgenda" do @a = Factory.build :meeting_agenda, :text => "Some content...\n\nMore content!\n\nExtraordinary content!!" end + # TODO: Test the right user and messages are set in the history describe "#lock!" do it "locks the agenda" do @a.save @@ -25,7 +26,7 @@ describe "MeetingAgenda" do end end - # a meeting agendat is editable when it is not locked + # a meeting agenda is editable when it is not locked describe "#editable?" do it "is editable when not locked" do @a.editable?.should be_true