Sha256: 0fe164a01dfb76802243777a47110f270ee940e724cd59f1b262edd13bc62078

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'

describe MediaMagick::Controller::Helpers do
  before do
    @controller = Class.new
    @controller.extend MediaMagick::Controller::Helpers
  end

  describe "getting doc by params" do
    before do
      @track = Track.new
      @album = Album.create(tracks: [@track])
    end

    context "document is embedded" do
      it "should get parent by params" do
        params = {
          :embedded_in_model => "album", 
          :embedded_in_id    => "#{@album.id.to_s}", 
          :model             => "track", 
          :model_id          => "#{@track.id.to_s}"
        }
        @controller.find_doc_by_params(params).should eq(@track)
      end
    end

    context "document is root" do
      it "should get parent by params" do
        params = {
          :model             => "album", 
          :model_id          => "#{@album.id.to_s}"
        }
        @controller.find_doc_by_params(params).should eq(@album)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
media_magick-0.2.0 spec/lib/media_magick/controller/helper_spec.rb
media_magick-0.1.1 spec/lib/media_magick/controller/helper_spec.rb