|
|
|
@ -44,16 +44,16 @@ describe DocumentsController do |
|
|
|
|
FactoryGirl.create(:document_category, project: project, name: "Default Category") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let(:document) { |
|
|
|
|
FactoryGirl.create(:document, title: "Sample Document", project: project, category: default_category) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
allow(User).to receive(:current).and_return admin |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "index" do |
|
|
|
|
|
|
|
|
|
let(:document) { |
|
|
|
|
FactoryGirl.create(:document, title: "Sample Document", project: project, category: default_category) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
document.update_attributes(description:<<LOREM) |
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula varius varius, ipsum massa fermentum orci, eget tristique ante sem vel mi. Nulla facilisi. Donec enim libero, luctus ac sagittis sit amet, vehicula sagittis magna. Duis ultrices molestie ante, eget scelerisque sem iaculis vitae. Etiam fermentum mauris vitae metus pharetra condimentum fermentum est pretium. Proin sollicitudin elementum quam quis pharetra. Aenean facilisis nunc quis elit volutpat mollis. Aenean eleifend varius euismod. Ut dolor est, congue eget dapibus eget, elementum eu odio. Integer et lectus neque, nec scelerisque nisi. EndOfLineHere |
|
|
|
@ -160,12 +160,34 @@ LOREM |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "destroy" do |
|
|
|
|
describe 'show' do |
|
|
|
|
before do |
|
|
|
|
document |
|
|
|
|
get :show, id: document.id |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
let(:document) { |
|
|
|
|
FactoryGirl.create(:document, title: "Sample Document", project: project, category: default_category) |
|
|
|
|
} |
|
|
|
|
it "should delete the document and redirect back to documents-page of the project" do |
|
|
|
|
expect(response).to be_success |
|
|
|
|
expect(response).to render_template('show') |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe '#add_attachment' do |
|
|
|
|
before do |
|
|
|
|
document |
|
|
|
|
post :add_attachment, |
|
|
|
|
id: document.id, |
|
|
|
|
attachments: { '1' => { description: "sample file", file: file_attachment } } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "should delete the document and redirect back to documents-page of the project" do |
|
|
|
|
expect(response).to be_redirect |
|
|
|
|
document.reload |
|
|
|
|
expect(document.attachments.length).to eq(1) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "destroy" do |
|
|
|
|
before do |
|
|
|
|
document |
|
|
|
|
end |
|
|
|
|