Merge pull request #51 from opf/fix/broken_strong_params

Fix/broken strong params
pull/6827/head
Oliver Günther 9 years ago
commit a6f31e91c2
  1. 6
      app/controllers/documents_controller.rb
  2. 4
      app/models/document_observer.rb
  3. 9
      spec/controllers/documents_controller_spec.rb
  4. 7
      spec/models/document_observer_spec.rb

@ -110,12 +110,8 @@ class DocumentsController < ApplicationController
end
private
def document_params
params.require(:document).permit('category_id', 'title', 'description')
end
private
def document_params
params.require(:document).permit('category_id', 'title', 'description')
params.fetch(:document, {}).permit('category_id', 'title', 'description')
end
end

@ -31,13 +31,11 @@
#++
class DocumentObserver < ActiveRecord::Observer
def after_create(document)
return unless Setting.notified_events.include?('document_added')
document.recipients.each do |user|
DocumentsMailer.document_added(user, document).deliver
DocumentsMailer.document_added(user, document).deliver_now
end
end
end

@ -83,6 +83,15 @@ LOREM
end
describe 'new' do
before do
get :new, project_id: project.id
end
it 'show the new document form' do
expect(response).to render_template(partial: 'documents/_form')
end
end
describe "create" do

@ -31,18 +31,15 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe DocumentObserver do
let(:user) { FactoryGirl.create(:user, firstname: 'Test', lastname: "User", mail: 'test@test.com') }
let(:project) { FactoryGirl.create(:project, name: "TestProject")}
let(:mail) do
mock = Object.new
allow(mock).to receive(:deliver)
allow(mock).to receive(:deliver_now)
mock
end
it "is triggered, when a document has been created" do
document = FactoryGirl.build(:document)
#observers are singletons, so any_instance exactly leaves out the singleton
@ -60,6 +57,4 @@ describe DocumentObserver do
document.save
end
end

Loading…
Cancel
Save