mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 21:31:28 +00:00
More test fixes for rails 4
This commit is contained in:
parent
88721b28df
commit
b35ba51910
6 changed files with 47 additions and 32 deletions
|
@ -3,6 +3,7 @@ class AboutController < ApplicationController
|
|||
end
|
||||
|
||||
def adminpanel
|
||||
raise AccessError unless cuser and @cuser.admin?
|
||||
end
|
||||
|
||||
def statistics
|
||||
|
|
|
@ -77,10 +77,13 @@ Ensl::Application.routes.draw do
|
|||
resources :bans
|
||||
resources :tweets
|
||||
resources :issues
|
||||
resources :posts
|
||||
|
||||
resources :brackets
|
||||
|
||||
get 'about/action'
|
||||
get 'about/staff'
|
||||
get 'about/adminpanel'
|
||||
get 'about/statistics'
|
||||
|
||||
get 'refresh', to: "application#refresh"
|
||||
|
|
|
@ -6,13 +6,22 @@ RSpec.describe AboutController, type: :controller do
|
|||
expect(response).to render_template("staff")
|
||||
end
|
||||
|
||||
it "renders the adminpanel template" do
|
||||
get :adminpanel
|
||||
expect(response).to render_template("adminpanel")
|
||||
end
|
||||
context 'as an admin' do
|
||||
# let!(:admin) { create(:user, :admin) }
|
||||
let!(:admin) { create :user, :admin }
|
||||
|
||||
it "renders the statistics template" do
|
||||
get :statistics
|
||||
expect(response).to render_template("statistics")
|
||||
before do
|
||||
sign_in_as(admin)
|
||||
end
|
||||
|
||||
it "renders the adminpanel template" do
|
||||
get :adminpanel
|
||||
expect(response).to render_template("adminpanel")
|
||||
end
|
||||
|
||||
it "renders the statistics template" do
|
||||
get :statistics
|
||||
expect(response).to render_template("statistics")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
|
||||
# Prevent database truncation if the environment is production
|
||||
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
||||
|
||||
require 'rails_helper'
|
||||
require 'rspec/rails'
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
|
@ -20,13 +22,20 @@ require 'rspec/rails'
|
|||
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
||||
# require only the support files necessary.
|
||||
#
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| print "importing " + f + "\r\n"; require f }
|
||||
|
||||
# Checks for pending migrations before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
#config.include Controllers::JsonHelpers, type: :controller
|
||||
config.include Features::FormHelpers, type: :feature
|
||||
config.include Features::ServerHelpers, type: :feature
|
||||
config.include Features::SessionHelpers, type: :feature
|
||||
config.include Features::SessionHelpers, type: :controller
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ RSpec.configure do |config|
|
|||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
# Capybara
|
||||
config.include Capybara::DSL
|
||||
|
||||
# rspec-mocks config goes here. You can use an alternate test double
|
||||
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
||||
config.mock_with :rspec do |mocks|
|
||||
|
@ -63,22 +66,12 @@ RSpec.configure do |config|
|
|||
|
||||
# The settings below are suggested to provide a good initial experience
|
||||
# with RSpec, but feel free to customize to your heart's content.
|
||||
=begin
|
||||
# These two settings work together to allow you to limit a spec run
|
||||
# to individual examples or groups you care about by tagging them with
|
||||
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
||||
# get run.
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include Controllers::JsonHelpers, type: :controller
|
||||
config.include Features::FormHelpers, type: :feature
|
||||
config.include Features::ServerHelpers, type: :feature
|
||||
config.include Features::SessionHelpers, type: :feature
|
||||
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
config.order = "random"
|
||||
config.use_transactional_fixtures = false
|
||||
config.color = true
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
module SpecLoginHelper
|
||||
def login_admin
|
||||
login(:admin)
|
||||
end
|
||||
|
||||
def login(user)
|
||||
user = User.where(:login => user.to_s).first if user.is_a?(Symbol)
|
||||
request.session[:user] = user.id
|
||||
end
|
||||
|
||||
def current_user
|
||||
User.find(request.session[:user])
|
||||
end
|
||||
end
|
||||
module SpecLoginHelper
|
||||
def login_admin
|
||||
login(:admin)
|
||||
end
|
||||
|
||||
def login(user)
|
||||
user = User.where(:login => user.to_s).first if user.is_a?(Symbol)
|
||||
request.session[:user] = user.id
|
||||
end
|
||||
|
||||
def current_user
|
||||
User.find(request.session[:user])
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue