diff options
author | 2011-07-05 13:15:05 +0300 | |
---|---|---|
committer | 2011-07-05 13:15:05 +0300 | |
commit | 2cc900875d83e616a53638dfad2a80d5565c3471 (patch) | |
tree | dfc5d8192e69c16cb1cc4e244dd4f52a6b44fb30 | |
parent | Application receives meeting log from IRC bot (diff) | |
parent | Display buttons on Agenda item view page in cleaner way (diff) | |
download | council-webapp-2cc900875d83e616a53638dfad2a80d5565c3471.tar.gz council-webapp-2cc900875d83e616a53638dfad2a80d5565c3471.tar.bz2 council-webapp-2cc900875d83e616a53638dfad2a80d5565c3471.zip |
Merge remote-tracking branch 'github/bugfix'
-rw-r--r-- | site/app/models/agenda.rb | 4 | ||||
-rw-r--r-- | site/app/models/user.rb | 3 | ||||
-rw-r--r-- | site/app/views/agenda_items/show.dryml | 10 | ||||
-rw-r--r-- | site/config/initializers/agenda.rb | 12 | ||||
-rw-r--r-- | site/features/agenda_items.feature | 10 | ||||
-rw-r--r-- | site/features/step_definitions/agenda_item_steps.rb | 12 | ||||
-rw-r--r-- | site/features/step_definitions/within_steps.rb | 2 | ||||
-rw-r--r-- | site/public/stylesheets/application.css | 4 | ||||
-rw-r--r-- | site/spec/models/agenda_spec.rb | 12 | ||||
-rw-r--r-- | site/spec/models/user_spec.rb | 6 |
10 files changed, 59 insertions, 16 deletions
diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb index 5580828..c15b12e 100644 --- a/site/app/models/agenda.rb +++ b/site/app/models/agenda.rb @@ -52,7 +52,9 @@ class Agenda < ActiveRecord::Base end def self.current - Agenda.state_is_not(:old).first + result = Agenda.state_is_not(:old).first + result = Agenda.create! unless result + result end def self.transitions_available(user) diff --git a/site/app/models/user.rb b/site/app/models/user.rb index 7809e87..cde0df5 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -58,6 +58,9 @@ class User < ActiveRecord::Base num_status = 0 agendas = Agenda.all :conditions => ['agendas.meeting_time BETWEEN ? AND ?', start_date, end_date], :order => :meeting_time + + return 'There were no meetings in this term yet' if agendas.count.zero? + for agenda in agendas if Participation.participant_is(self).agenda_is(agenda).count == 0 num_status += 1 if num_status < 3 diff --git a/site/app/views/agenda_items/show.dryml b/site/app/views/agenda_items/show.dryml index 1713266..b0b425d 100644 --- a/site/app/views/agenda_items/show.dryml +++ b/site/app/views/agenda_items/show.dryml @@ -1,16 +1,22 @@ <show-page> - <append-content:> + <append-content-body:> + <div> + <span class="one-button-form"> <form if="&this.editable_by?(current_user, :agenda) and this.agenda.nil?"> <input value="&Agenda.current.id" type="hidden" name="agenda_item[agenda_id]"/> <submit label="Add to current agenda"/> </form> + </span> + <span class="one-button-form"> <form if="&this.editable_by?(current_user, :rejected)"> <input value="&!this.rejected?" type="hidden" name="agenda_item[rejected]"/> <submit label="Reject" unless="&this.rejected"/> <submit label="Un-reject" if="&this.rejected"/> </form> - </append-content:> + </span> + </div> + </append-content-body:> <after-collection:> <form if="&VotingOption.new.creatable_by?(current_user)" action="&create_voting_option_path"> diff --git a/site/config/initializers/agenda.rb b/site/config/initializers/agenda.rb deleted file mode 100644 index bdd35b9..0000000 --- a/site/config/initializers/agenda.rb +++ /dev/null @@ -1,12 +0,0 @@ -# If there are no active agendas create one -begin - return unless ['development', 'production'].include? Rails.env - return if Agenda.state_is_not(:old).count > 0 - Agenda.create! -rescue - # Just ignore it. It will happen when: - # * Everything is fine, but database is missing (eg. rake db:schema:load) - # * It's safe to ignore this then - # * Something is seriously wrong (like broken db) - # * Users will notice this anyway -end diff --git a/site/features/agenda_items.feature b/site/features/agenda_items.feature index 114b8a4..18d301f 100644 --- a/site/features/agenda_items.feature +++ b/site/features/agenda_items.feature @@ -44,3 +44,13 @@ Feature: Suggest Agenda Items When I am on newest agenda item page Then I should not see "Add to current agenda" button And I should not see "Reject" button + + Scenario: Reject and Add to current agenda buttons displayed nicely + Given example agenda item + And an agenda + And I am logged in as a council member + When I am on the first suggested agenda page + Then I should see "Reject" button inside content body + And "Reject" button should be inline + And I should see "Add to current agenda" button inside content body + And "Add to current agenda" button should be inline diff --git a/site/features/step_definitions/agenda_item_steps.rb b/site/features/step_definitions/agenda_item_steps.rb index 22348e8..5bf5de2 100644 --- a/site/features/step_definitions/agenda_item_steps.rb +++ b/site/features/step_definitions/agenda_item_steps.rb @@ -27,3 +27,15 @@ Given /^agenda item in current agenda$/ do Agenda.create! AgendaItem.create! :agenda => Agenda.last, :title => 'Item in current agenda' end + +Then /^I should see "([^"]*)" button inside content body$/ do |arg1| + within('.content-body') do + page.all(:xpath, "//input[@type='submit'][@value='#{arg1}']").should_not be_empty + end +end + +Then /^"([^"]*)" button should be inline$/ do |arg1| + within('.one-button-form') do + page.all(:xpath, "//input[@type='submit'][@value='#{arg1}']").should_not be_empty + end +end diff --git a/site/features/step_definitions/within_steps.rb b/site/features/step_definitions/within_steps.rb index 821eb61..a36a4af 100644 --- a/site/features/step_definitions/within_steps.rb +++ b/site/features/step_definitions/within_steps.rb @@ -2,9 +2,9 @@ 'as current agenda' => '.current-agenda', 'as agenda state' => '.state-tag.view.agenda-state', 'as transition' => '.transition', + 'inside content body' => '.content-body', 'in the notices' => '.flash.notice', 'in the errors' => '.error-messages', - 'in the content body' => '.content-body', 'in the agenda items' => '.agenda-items', 'in the agendas collection' => '.collection.agendas', 'as empty collection message' => '.empty-collection-message', diff --git a/site/public/stylesheets/application.css b/site/public/stylesheets/application.css index e69de29..2ac85eb 100644 --- a/site/public/stylesheets/application.css +++ b/site/public/stylesheets/application.css @@ -0,0 +1,4 @@ +.one-button-form{ + float: left; + margin: 5pt; +} diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb index 12b38a3..f1de822 100644 --- a/site/spec/models/agenda_spec.rb +++ b/site/spec/models/agenda_spec.rb @@ -243,6 +243,18 @@ describe Agenda do end end + describe '#current?' do + it 'should create new agenda if needed' do + Agenda.count.should be_zero + agenda = Agenda.current + agenda2 = Agenda.current + agenda.should be_a(Agenda) + agenda2.should be_a(Agenda) + Agenda.count.should be_equal(1) + agenda.id.should be_equal(agenda2.id) + end + end + it 'should return proper voting_array' do old_agenda = Factory(:agenda, :state => 'old') current_agenda = Factory(:agenda) diff --git a/site/spec/models/user_spec.rb b/site/spec/models/user_spec.rb index 5246015..ad36761 100644 --- a/site/spec/models/user_spec.rb +++ b/site/spec/models/user_spec.rb @@ -81,6 +81,12 @@ describe User do u.slacking_status_in_period(agendas.first.meeting_time - 1.minute, agendas.last.meeting_time + 1.minute).should == 'No more a council' end + + it 'should return "There were no meetings in this term yet" if there were no meeting yet' do + a = Factory(:agenda, :meeting_time => 1.year.from_now) + u = users_factory(:council) + u.slacking_status_in_period(1.year.ago, 1.month.from_now).should == "There were no meetings in this term yet" + end end it 'should allow no one to create' do |