Merge pull request #47 from finnlabs/feature/rspec-299

RSpec 2.99 Upgrade
pull/6827/head
ulferts 10 years ago
commit 452fed1ba7
  1. 4
      spec/controllers/meeting_agendas_controller_spec.rb
  2. 6
      spec/controllers/meeting_minutes_controller_spec.rb
  3. 48
      spec/controllers/meetings_controller_spec.rb
  4. 30
      spec/mailers/meeting_mailer_spec.rb
  5. 10
      spec/models/meeting_agenda_spec.rb
  6. 2
      spec/models/meeting_content_journal_spec.rb
  7. 8
      spec/models/meeting_minutes_spec.rb
  8. 48
      spec/models/meeting_spec.rb
  9. 42
      spec/models/user_deletion_spec.rb
  10. 2
      spec/routing/previews_routing_spec.rb
  11. 2
      spec/support/plugin_spec_helper.rb

@ -20,11 +20,11 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe MeetingAgendasController do
describe MeetingAgendasController, :type => :controller do
let(:meeting) { FactoryGirl.create(:meeting) }
let(:user) { FactoryGirl.create(:admin) }
before { User.stub(:current).and_return(user) }
before { allow(User).to receive(:current).and_return(user) }
describe 'preview' do
let(:text) { "Meeting agenda content" }

@ -20,16 +20,16 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe MeetingMinutesController do
describe MeetingMinutesController, :type => :controller do
let(:meeting) { FactoryGirl.create(:meeting) }
let(:user) { FactoryGirl.create(:admin) }
before { User.stub(:current).and_return(user) }
before { allow(User).to receive(:current).and_return(user) }
describe 'preview' do
let(:text) { "Meeting minutes content" }
before { MeetingMinutes.any_instance.stub(:editable?).and_return(true) }
before { allow_any_instance_of(MeetingMinutes).to receive(:editable?).and_return(true) }
it_behaves_like 'valid preview' do
let(:preview_texts) { [text] }

@ -20,79 +20,79 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe MeetingsController do
describe MeetingsController, :type => :controller do
before(:each) do
@p = mock_model(Project)
@controller.stub!(:authorize)
@controller.stub!(:check_if_login_required)
allow(@controller).to receive(:authorize)
allow(@controller).to receive(:check_if_login_required)
end
describe "GET" do
describe "index" do
before(:each) do
Project.stub!(:find).and_return(@p)
allow(Project).to receive(:find).and_return(@p)
@ms = [mock_model(Meeting), mock_model(Meeting), mock_model(Meeting)]
@ms.stub!(:from_tomorrow).and_return(@ms)
@p.stub!(:meetings).and_return(@ms)
allow(@ms).to receive(:from_tomorrow).and_return(@ms)
allow(@p).to receive(:meetings).and_return(@ms)
[:with_users_by_date, :page, :per_page].each do |meth|
@ms.should_receive(meth).and_return(@ms)
expect(@ms).to receive(meth).and_return(@ms)
end
@grouped = double('grouped')
Meeting.should_receive(:group_by_time).with(@ms).and_return(@grouped)
expect(Meeting).to receive(:group_by_time).with(@ms).and_return(@grouped)
end
describe "html" do
before(:each) do
get "index", :project_id => @p.id
end
it {response.should be_success}
it {assigns(:meetings_by_start_year_month_date).should eql @grouped }
it {expect(response).to be_success}
it {expect(assigns(:meetings_by_start_year_month_date)).to eql @grouped }
end
end
describe "show" do
before(:each) do
@m = mock_model(Meeting)
Meeting.stub!(:find).and_return(@m)
@m.stub!(:project).and_return(@p)
@m.stub!(:agenda).stub!(:present?).and_return(false)
allow(Meeting).to receive(:find).and_return(@m)
allow(@m).to receive(:project).and_return(@p)
allow(allow(@m).to receive(:agenda)).to receive(:present?).and_return(false)
end
describe "html" do
before(:each) do
get "show", :id => @m.id
end
it {response.should be_success}
it {expect(response).to be_success}
end
end
describe "new" do
before(:each) do
Project.stub!(:find).and_return(@p)
allow(Project).to receive(:find).and_return(@p)
@m = mock_model(Meeting)
@m.stub!(:project=)
@m.stub!(:author=)
Meeting.stub!(:new).and_return(@m)
allow(@m).to receive(:project=)
allow(@m).to receive(:author=)
allow(Meeting).to receive(:new).and_return(@m)
end
describe "html" do
before(:each) do
get "new", :project_id => @p.id
end
it {response.should be_success}
it {assigns(:meeting).should eql @m}
it {expect(response).to be_success}
it {expect(assigns(:meeting)).to eql @m}
end
end
describe "edit" do
before(:each) do
@m = mock_model(Meeting)
Meeting.stub!(:find).and_return(@m)
@m.stub(:project).and_return(@p)
allow(Meeting).to receive(:find).and_return(@m)
allow(@m).to receive(:project).and_return(@p)
end
describe "html" do
before(:each) do
get "edit", :id => @m.id
end
it {response.should be_success}
it {assigns(:meeting).should eql @m}
it {expect(response).to be_success}
it {expect(assigns(:meeting)).to eql @m}
end
end
end

@ -20,7 +20,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe MeetingMailer do
describe MeetingMailer, :type => :mailer do
let(:role) { FactoryGirl.create(:role, permissions: [:view_meetings]) }
let(:project) { FactoryGirl.create(:project) }
let(:author) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) }
@ -50,13 +50,13 @@ describe MeetingMailer do
it "renders the headers" do
mail.subject.should include(meeting.project.name)
mail.subject.should include(meeting.title)
mail.to.should include(author.mail)
mail.from.should eq([Setting.mail_from])
mail.cc.should_not include(author.mail)
mail.cc.should include(watcher1.mail)
mail.cc.should include(watcher2.mail)
expect(mail.subject).to include(meeting.project.name)
expect(mail.subject).to include(meeting.title)
expect(mail.to).to include(author.mail)
expect(mail.from).to eq([Setting.mail_from])
expect(mail.cc).not_to include(author.mail)
expect(mail.cc).to include(watcher1.mail)
expect(mail.cc).to include(watcher2.mail)
end
it "renders the text body" do
@ -69,13 +69,13 @@ describe MeetingMailer do
end
def check_meeting_mail_content(body)
body.should include(meeting.project.name)
body.should include(meeting.title)
body.should include(i18n.format_date meeting.start_date)
body.should include(i18n.format_time meeting.start_time, false)
body.should include(i18n.format_time meeting.end_time, false)
body.should include(@participants[0].name)
body.should include(@participants[1].name)
expect(body).to include(meeting.project.name)
expect(body).to include(meeting.title)
expect(body).to include(i18n.format_date meeting.start_date)
expect(body).to include(i18n.format_time meeting.start_time, false)
expect(body).to include(i18n.format_time meeting.end_time, false)
expect(body).to include(@participants[0].name)
expect(body).to include(@participants[1].name)
end
def save_and_open_mail_html_body(mail)

@ -20,7 +20,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe "MeetingAgenda" do
describe "MeetingAgenda", :type => :model do
before(:each) do
@a = FactoryGirl.build :meeting_agenda, :text => "Some content...\n\nMore content!\n\nExtraordinary content!!"
end
@ -32,7 +32,7 @@ describe "MeetingAgenda" do
@a.reload
@a.lock!
@a.reload
@a.locked.should be_true
expect(@a.locked).to be_truthy
end
end
@ -43,7 +43,7 @@ describe "MeetingAgenda" do
@a.reload
@a.unlock!
@a.reload
@a.locked.should be_false
expect(@a.locked).to be_falsey
end
end
@ -51,11 +51,11 @@ describe "MeetingAgenda" do
describe "#editable?" do
it "is editable when not locked" do
@a.locked = false
@a.editable?.should be_true
expect(@a.editable?).to be_truthy
end
it "is not editable when locked" do
@a.locked = true
@a.editable?.should be_false
expect(@a.editable?).to be_falsey
end
end
end

@ -22,7 +22,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
require 'journal/meeting_content_journal'
describe Journal do
describe Journal, :type => :model do
include PluginSpecHelper
let(:journal) { FactoryGirl.build(:meeting_content_journal) }

@ -20,7 +20,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe "MeetingMinutes" do
describe "MeetingMinutes", :type => :model do
before do
@min = FactoryGirl.build :meeting_minutes
end
@ -33,7 +33,7 @@ describe "MeetingMinutes" do
end
describe "with no agenda present" do
it "is not editable" do
@min.editable?.should be_false
expect(@min.editable?).to be_falsey
end
end
describe "with an agenda present" do
@ -42,11 +42,11 @@ describe "MeetingMinutes" do
@mee.agenda = @a
end
it "is not editable when the agenda is open" do
@min.editable?.should be_false
expect(@min.editable?).to be_falsey
end
it "is editable when the agenda is closed" do
@a.lock!
@min.editable?.should be_true
expect(@min.editable?).to be_truthy
end
end
end

@ -20,12 +20,12 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe Meeting do
it {should belong_to :project}
it {should belong_to :author}
it {should validate_presence_of :title}
it {should validate_presence_of :start_time}
it {pending; should accept_nested_attributes_for :participants} # geht das?
describe Meeting, :type => :model do
it {is_expected.to belong_to :project}
it {is_expected.to belong_to :author}
it {is_expected.to validate_presence_of :title}
it {is_expected.to validate_presence_of :start_time}
it {skip; is_expected.to accept_nested_attributes_for :participants} # geht das?
let(:project) { FactoryGirl.create(:project) }
let(:user1) { FactoryGirl.create(:user) }
@ -43,34 +43,34 @@ describe Meeting do
end
describe "to_s" do
it {@m.to_s.should == "dingens"}
it {expect(@m.to_s).to eq("dingens")}
end
describe "start_date" do
it {@m.start_date.should == Date.tomorrow}
it {expect(@m.start_date).to eq(Date.tomorrow)}
end
describe "start_month" do
it {@m.start_month.should == Date.tomorrow.month}
it {expect(@m.start_month).to eq(Date.tomorrow.month)}
end
describe "start_year" do
it {@m.start_year.should == Date.tomorrow.year}
it {expect(@m.start_year).to eq(Date.tomorrow.year)}
end
describe "end_time" do
it {@m.end_time.should == Date.tomorrow + 11.hours}
it {expect(@m.end_time).to eq(Date.tomorrow + 11.hours)}
end
describe "time-sorted finder" do
it {pending}
it {skip}
end
describe "Journalized Objects" do
before(:each) do
@project ||= FactoryGirl.create(:project_with_types)
@current = FactoryGirl.create(:user, :login => "user1", :mail => "user1@users.com")
User.stub!(:current).and_return(@current)
allow(User).to receive(:current).and_return(@current)
end
it 'should work with meeting' do
@ -78,7 +78,7 @@ describe Meeting do
initial_journal = @meeting.journals.first
recreated_journal = @meeting.recreate_initial_journal!
initial_journal.identical?(recreated_journal).should be true
expect(initial_journal.identical?(recreated_journal)).to be true
end
end
@ -90,7 +90,7 @@ describe Meeting do
end
it "should contain the user" do
meeting.all_changeable_participants.should == [user1]
expect(meeting.all_changeable_participants).to eq([user1])
end
end
@ -106,7 +106,7 @@ describe Meeting do
end
it "should not contain the user" do
meeting.all_changeable_participants.include?(user2).should be_false
expect(meeting.all_changeable_participants.include?(user2)).to be_falsey
end
end
@ -117,7 +117,7 @@ describe Meeting do
end
it "should contain the user" do
meeting.all_changeable_participants.include?(locked_user).should be_true
expect(meeting.all_changeable_participants.include?(locked_user)).to be_truthy
end
end
end
@ -133,7 +133,7 @@ describe Meeting do
meeting.save!
end
it { meeting.watchers.collect(&:user).should =~ [user1, user2] }
it { expect(meeting.watchers.collect(&:user)).to match_array([user1, user2]) }
end
describe :close_agenda_and_copy_to_minutes do
@ -144,11 +144,11 @@ describe Meeting do
end
it "should create a meeting with the agenda's text" do
meeting.minutes.text.should == meeting.agenda.text
expect(meeting.minutes.text).to eq(meeting.agenda.text)
end
it "should close the agenda" do
meeting.agenda.locked?.should be_true
expect(meeting.agenda.locked?).to be_truthy
end
end
@ -166,22 +166,22 @@ describe Meeting do
it "should have the same start_time as the original meeting" do
copy = meeting.copy({})
copy.start_time.should == meeting.start_time
expect(copy.start_time).to eq(meeting.start_time)
end
it "should delete the copied meeting author if no author is given as parameter" do
copy = meeting.copy({})
copy.author.should be_nil
expect(copy.author).to be_nil
end
it "should set the author to the provided author if one is given" do
copy = meeting.copy :author => user2
copy.author.should == user2
expect(copy.author).to eq(user2)
end
it "should clear participant ids and attended flags for all copied attendees" do
copy = meeting.copy({})
copy.participants.all?{ |p| p.id.nil? && !p.attended }.should be_true
expect(copy.participants.all?{ |p| p.id.nil? && !p.attended }).to be_truthy
end
end
end

@ -20,7 +20,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe User, "#destroy" do
describe User, :type => :model, "#destroy" do
let(:user) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
let(:substitute_user) { DeletedUser.first }
@ -43,13 +43,13 @@ describe User, "#destroy" do
shared_examples_for "updated journalized associated object" do
before do
User.stub(:current).and_return(user2)
allow(User).to receive(:current).and_return(user2)
associations.each do |association|
associated_instance.send(association.to_s + "=", user2)
end
associated_instance.save!
User.stub(:current).and_return(user) # in order to have the content journal created by the user
allow(User).to receive(:current).and_return(user) # in order to have the content journal created by the user
associated_instance.reload
associations.each do |association|
associated_instance.send(association.to_s + "=", user)
@ -60,35 +60,35 @@ describe User, "#destroy" do
associated_instance.reload
end
it { associated_class.find_by_id(associated_instance.id).should == associated_instance }
it { expect(associated_class.find_by_id(associated_instance.id)).to eq(associated_instance) }
it "should replace the user on all associations" do
associations.each do |association|
associated_instance.send(association).should == substitute_user
expect(associated_instance.send(association)).to eq(substitute_user)
end
end
it { associated_instance.journals.first.user.should == user2 }
it { expect(associated_instance.journals.first.user).to eq(user2) }
it "should update first journal changes" do
associations.each do |association|
associated_instance.journals.first.changed_data[(association.to_s + "_id").to_sym].last.should == user2.id
expect(associated_instance.journals.first.changed_data[(association.to_s + "_id").to_sym].last).to eq(user2.id)
end
end
it { associated_instance.journals.last.user.should == substitute_user }
it { expect(associated_instance.journals.last.user).to eq(substitute_user) }
it "should update second journal changes" do
associations.each do |association|
associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].last.should == substitute_user.id
expect(associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].last).to eq(substitute_user.id)
end
end
end
shared_examples_for "created journalized associated object" do
before do
User.stub(:current).and_return(user) # in order to have the content journal created by the user
allow(User).to receive(:current).and_return(user) # in order to have the content journal created by the user
associations.each do |association|
associated_instance.send(association.to_s + "=", user)
end
associated_instance.save!
User.stub(:current).and_return(user2)
allow(User).to receive(:current).and_return(user2)
associated_instance.reload
associations.each do |association|
associated_instance.send(association.to_s + "=", user2)
@ -99,23 +99,23 @@ describe User, "#destroy" do
associated_instance.reload
end
it { associated_class.find_by_id(associated_instance.id).should == associated_instance }
it { expect(associated_class.find_by_id(associated_instance.id)).to eq(associated_instance) }
it "should keep the current user on all associations" do
associations.each do |association|
associated_instance.send(association).should == user2
expect(associated_instance.send(association)).to eq(user2)
end
end
it { associated_instance.journals.first.user.should == substitute_user }
it { expect(associated_instance.journals.first.user).to eq(substitute_user) }
it "should update the first journal" do
associations.each do |association|
associated_instance.journals.first.changed_data[(association.to_s + "_id").to_sym].last.should == substitute_user.id
expect(associated_instance.journals.first.changed_data[(association.to_s + "_id").to_sym].last).to eq(substitute_user.id)
end
end
it { associated_instance.journals.last.user.should == user2 }
it { expect(associated_instance.journals.last.user).to eq(user2) }
it "should update the last journal" do
associations.each do |association|
associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].first.should == substitute_user.id
associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].last.should == user2.id
expect(associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].first).to eq(substitute_user.id)
expect(associated_instance.journals.last.changed_data[(association.to_s + "_id").to_sym].last).to eq(user2.id)
end
end
end
@ -182,8 +182,8 @@ describe User, "#destroy" do
participant.reload
end
it { meeting.participants.map(&:user).should =~ [DeletedUser.first, user2] }
it { participant.invited.should be_true }
it { participant.attended.should be_true }
it { expect(meeting.participants.map(&:user)).to match_array([DeletedUser.first, user2]) }
it { expect(participant.invited).to be_truthy }
it { expect(participant.attended).to be_truthy }
end
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe 'preview' do
describe 'preview', :type => :routing do
it "should connect POST /meetings/:meeting_id/agenda/preview to meeting_agendas#preview" do
expect(post("/meetings/1/agenda/preview")).to route_to(controller: 'meeting_agendas',
meeting_id: '1',

@ -33,7 +33,7 @@ module PluginSpecHelper
journal.reload
end
it { journal.changed_data[:text][1].should == text }
it { expect(journal.changed_data[:text][1]).to eq(text) }
end
end
end

Loading…
Cancel
Save