Sha256: b63a8be55246f2c7db58433d6b341bbd7d4626fc260306531de54de9373b51e4

Contents?: true

Size: 1.61 KB

Versions: 23

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

describe ActiveMetadata::NotesController do


    before(:each) do
      @document = Document.create! { |d| d.name = "John" }
    end

    describe "GET 'index'" do

      render_views

      before(:each) do
        (1..3).each do |i|
          @document.create_note_for(:name, "note#{i}")
        end
      end

      it "should success" do
        get 'index', :model_name => 'document', :model_id => @document.id, :field_name => 'name'
        response.should be_success
      end

      it "should assign notes" do
        get 'index', :model_name => 'document', :model_id => @document.id, :field_name => 'name'
        assigns(:notes).should_not be_nil
        assigns(:notes).size.should eq 3
      end

      it "should display 3 notes" do
        get 'index', :model_name => 'document', :model_id => @document.id, :field_name => 'name'
        response.body.should match(/note1/)
        response.body.should match(/note2/)
        response.body.should match(/note3/)
      end

    end

    describe "#create" do

      it "should create a note for a passed group" do
        post :create, :model_name => 'document', :model_id => @document.id, :field_name => 'name', :group => "my_group", :format => :js
        response.should be_success
        ActiveMetadata::Stream.by_group("my_group").count.should eq 1
      end

      it "should create a starred note" do
        post :create, :model_name => 'document', :model_id => @document.id, :field_name => 'name', :starred => true, :format => :js
        response.should be_success
        @document.notes_for(:name).last.should be_starred
      end

    end


end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_metadata-0.8.9 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.8 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.7.1 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.7 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.6 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.5.2 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.5.1 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.5 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.4 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.3.1 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.3 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.2 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.1 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.8.0 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.9 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.8 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.7 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.6 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.5 spec/controllers/active_metadata/notes_controller_spec.rb
active_metadata-0.7.4 spec/controllers/active_metadata/notes_controller_spec.rb