Sha256: 821b98126b90e52a4cbb71dbf65f2903460db9cf8b052b8a0fe94417742930cc

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

require "spec_helper"

describe Detour::FeaturesController do
  routes { Detour::Engine.routes }

  describe "POST #create" do
    before do
      post :create, format: :js, feature: feature_params
    end

    context "when successful" do
      let(:feature_params) { { name: "foo_feature" } }

      it "sets a flash message" do
        flash[:notice].should eq "Your feature has been successfully created."
      end

      it "renders the success template" do
        response.should render_template "success"
      end
    end

    context "when unsuccessful" do
      let(:feature_params) { { name: "" } }

      it "renders the errors template" do
        response.should render_template "error"
      end
    end
  end

  describe "DELETE #destroy" do
    let!(:feature) { create :feature }

    before do
      delete :destroy, format: :js, id: feature.id, flaggable_type: :users
    end

    it "destroys the feature" do
      Detour::Feature.find_by_id(feature.id).should be_nil
    end

    it "displays a flash message" do
      flash[:notice].should eq "Feature #{feature.name} has been deleted."
    end

    it "renders the destroyed template" do
      response.should redirect_to flags_path(:users)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
detour-0.0.15 spec/controllers/detour/features_controller_spec.rb
detour-0.0.14 spec/controllers/detour/features_controller_spec.rb
detour-0.0.13 spec/controllers/detour/features_controller_spec.rb
detour-0.0.12 spec/controllers/detour/features_controller_spec.rb
detour-0.0.11 spec/controllers/detour/features_controller_spec.rb
detour-0.0.10 spec/controllers/detour/features_controller_spec.rb
detour-0.0.9 spec/controllers/detour/features_controller_spec.rb
detour-0.0.7 spec/controllers/detour/features_controller_spec.rb
detour-0.0.6 spec/controllers/detour/features_controller_spec.rb
detour-0.0.5 spec/controllers/detour/features_controller_spec.rb
detour-0.0.3 spec/controllers/detour/features_controller_spec.rb
detour-0.0.2 spec/controllers/detour/features_controller_spec.rb