Sha256: a01a0d06b03033c99cbc4fe793689d7257aa1a36795d96f8c113f3b5dc6ced22

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'chartkick/remote'

AnonymousRoutes = ActionDispatch::Routing::RouteSet.new.tap do |routes|
  routes.draw { resources :anonymous }
end

describe Chartkick::Remote, type: :controller do
  render_views

  AnonymousController = Class.new(ActionController::Base) do
    include Chartkick::Remote

    prepend_view_path 'spec/controllers/views'

    include AnonymousRoutes.url_helpers
    helper AnonymousRoutes.url_helpers

    def index
    end
  end

  controller AnonymousController do
    chartkick_remote
  end

  describe "GET" do
    routes { AnonymousRoutes }

    it "generates a remote data source" do
      get :index, format: :html
      expect(response.body).to include '_chartkick_remote_chart_id=1'
    end

    it "returns the remote data source as json" do
      get :index, _chartkick_remote_chart_id: 1, format: :json
      expect(JSON.parse(response.body)).to eq [[0,1]]
    end

    describe "when the standalone option is set" do
      controller AnonymousController do
        chartkick_remote standalone: true
      end

      it "does not show any other charts but the selected chart" do
        get :index, _chartkick_remote_chart_id: 1, _chartkick_remote_standalone: 1, format: :html

        expect(response.body).to have_tag :div, 'Skipped' #, count: 1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chartkick-remote-1.1.6 spec/controllers/remote_spec.rb
chartkick-remote-1.0.2 spec/controllers/remote_spec.rb