Sha256: c4553332a4122e463b468d6f2a4e8535911791517c795c1431b6a3c38e79c354

Contents?: true

Size: 1.69 KB

Versions: 12

Compression:

Stored size: 1.69 KB

Contents

require "rails_helper"

module ThinkFeelDoDashboard
  module SocialNetworking
    RSpec.describe ProfileQuestionsController, type: :controller do
      routes { Engine.routes }

      describe "GET edit" do
        context "for authenticated users" do
          let(:group) { instance_double(Group) }
          let(:user) { instance_double(User, admin?: true) }

          before do
            sign_in_user user
          end

          describe "when ProfileQuestion is found" do
            before do
              expect(::SocialNetworking::ProfileQuestion)
                .to receive(:find) do
                  double("ProfileQuestion")
                end
            end

            describe "when Group is found" do
              before do
                expect(Group).to receive(:find) { group }
              end

              it "should respond with a redirect to the moderator's profile page" do
                get :edit, group_id: 1, id: 1

                expect(response.status).to eq 200
              end
            end

            describe "when Group is not found" do
              it "should respond with a redirect" do
                get :edit, group_id: 1, id: 1

                expect(response.status).to eq 302
              end
            end
          end

          describe "when ProfileQuestion is not found" do
            it "should respond with a redirect" do
              get :edit, group_id: 1, id: 1

              expect(response.status).to eq 302
            end
          end
        end

        context "for unauthenticated users" do
          before { get :edit, group_id: 1, id: 1 }

          it_behaves_like "a rejected user action"
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.2.0.beta1 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.21 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.20 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.19 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.18 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.17 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.16 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.15 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.14 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.13 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.12 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb
think_feel_do_dashboard-1.1.11 spec/controllers/think_feel_do_dashboard/social_networking/profile_questions_controller_spec.rb