OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add model spec
Oliver Güntherfdbe56e00cfb
diff --git a/modules/ifc_models/spec/models/ifc_model_spec.rb b/modules/ifc_models/spec/models/ifc_model_spec.rbnew file mode 100644index 00000000000..e7c00255819--- /dev/null+++ b/modules/ifc_models/spec/models/ifc_model_spec.rb@@ -0,0 +1,41 @@+require 'spec_helper'++describe ::IFCModels::IFCModel, type: :model do+ subject { described_class.new params }+ let(:params) { { title: 'foo', is_default: true } }++ describe 'converted?' do+ let(:attachment) { FactoryBot.build :attachment }+ it 'is converted when xkt and metadata attachments are present' do+ expect(subject).not_to be_converted++ allow(subject).to receive(:xkt_attachment).and_return(attachment)+ allow(subject).to receive(:metadata_attachment).and_return(attachment)++ expect(subject).to be_converted+ end+ end++ describe 'ifc_attachment=' do+ subject { FactoryBot.create :ifc_model_converted }+ let(:ifc_attachment) { subject.ifc_attachment }+ let(:new_attachment) {+ FileHelpers.mock_uploaded_file name: "model.ifc", content_type: 'application/binary', binary: true+ }++ it 'replaces the previous attachment' do+ expect(ifc_attachment).to be_present+ expect(subject.xkt_attachment).to be_present+ expect(subject.metadata_attachment).to be_present+ expect(subject).to be_converted++ subject.ifc_attachment = new_attachment+ expect { ifc_attachment.reload }.to raise_error(ActiveRecord::RecordNotFound)++ expect(subject.ifc_attachment).not_to eq ifc_attachment+ expect(subject.ifc_attachment).not_to be_present+ expect(subject.xkt_attachment).not_to be_present+ expect(subject).not_to be_converted+ end+ end+end\ No newline at end of file