forked from bofh/fetsite
neuigkeit controller spec
This commit is contained in:
11
README_productive.md
Normal file
11
README_productive.md
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
install ruby/fetsite requirements
|
||||
|
||||
do all the rvm stuff
|
||||
|
||||
apt-get install git
|
||||
|
||||
chown fetsite /srv
|
||||
|
||||
su fetsite
|
||||
cd /srv
|
||||
@@ -145,9 +145,10 @@ end
|
||||
@calentries<< Calentry.new
|
||||
|
||||
end
|
||||
|
||||
def find_link
|
||||
@rubrik=@neuigkeit.rubrik
|
||||
if can?(:shownonpublic, Rubrik)
|
||||
if can?(:shownonpublic, Rubrik)
|
||||
@rubriken = Rubrik.all
|
||||
else
|
||||
@rubriken = Rubrik.where(:public=>true)
|
||||
@@ -156,7 +157,8 @@ end
|
||||
@calentries1=@neuigkeit.calentries
|
||||
nlink_search = Neuigkeit::LINKTYPES.clone
|
||||
nlink_search.collect!{|t| t.constantize}
|
||||
# @nlink_search.collect!{|t| t.search(params[:query]).limit(2)}
|
||||
|
||||
# @nlink_search.collect!{|t| t.search(params[:query]).limit(2)}
|
||||
@results= Sunspot.search nlink_search do
|
||||
fulltext params[:query]
|
||||
end
|
||||
@@ -168,6 +170,7 @@ end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def create_link
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
|
||||
@@ -178,6 +181,7 @@ end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def delete_link
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
@nlink = @neuigkeit.nlinks.find(params[:nlink_id])
|
||||
@@ -187,6 +191,7 @@ end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@neuigkeit = Neuigkeit.new(params[:neuigkeit])
|
||||
@neuigkeit.author=current_user
|
||||
|
||||
@@ -2,22 +2,22 @@ production:
|
||||
solr:
|
||||
hostname: localhost
|
||||
port: 8080
|
||||
log_level: WARNING
|
||||
min_memory: 32M
|
||||
max_memory: 1G
|
||||
path: /solr-4.10.2/default #production #ollection1 #production
|
||||
# log_level: WARNING
|
||||
# min_memory: 32M
|
||||
# max_memory: 1G
|
||||
# path: /solr-4.10.2/default #production #ollection1 #production
|
||||
# solr_home: solr
|
||||
# read_timeout: 2
|
||||
# open_timeout: 0.5
|
||||
|
||||
development:
|
||||
solr:
|
||||
hostname: triton-amp.local
|
||||
port: 8080
|
||||
hostname: localhost
|
||||
port: 8983
|
||||
log_level: INFO
|
||||
path: /solr/mycore
|
||||
min_memory: 32M
|
||||
max_memory: 1G
|
||||
path: /solr/fetsite_test
|
||||
# min_memory: 32M
|
||||
# max_memory: 1G
|
||||
# solr:
|
||||
# hostname: localhost
|
||||
# port: 8983
|
||||
|
||||
@@ -14,6 +14,7 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
||||
let(:assigned_object_variable){neuigkeit}
|
||||
|
||||
#let(:allow_fet_user) {allow(@controller).to receive(:current_user).and_return(fet_user)}
|
||||
let(:object_url) {rubrik_neuigkeit_url(neuigkeit.rubrik,neuigkeit)}
|
||||
|
||||
|
||||
describe "GET #show" do
|
||||
@@ -33,7 +34,7 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
||||
end
|
||||
|
||||
it "denys access to unpublished news" do
|
||||
neuigkeit=FactoryGirl.create(:neuigkeit, :unpublished)
|
||||
neuigkeit=FactoryGirl.create(:neuigkeit, :with_rubrik, :unpublished)
|
||||
get :show, {id: neuigkeit.id}, valid_session
|
||||
expect(response).to have_http_status(302)
|
||||
end
|
||||
@@ -51,17 +52,17 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
||||
expect(response.body).to match neuigkeit.name
|
||||
end
|
||||
it "has only links to external rubrik" do
|
||||
get :show, {id: neuigkeit.id}, public_session
|
||||
expect(response.body).to match rubrik.name
|
||||
expect(response.body).not_to match intern_rubrik.name
|
||||
get :show, {id: neuigkeit.id}, valid_session
|
||||
expect(response.body).to match neuigkeit.rubrik.name
|
||||
expect(response.body).not_to match intern_neuigkeit.rubrik.name
|
||||
end
|
||||
|
||||
context "and fet user" do
|
||||
with_fet_user
|
||||
it "has all links to internal and external rubriken" do
|
||||
action
|
||||
expect(response.body).to match intern_rubrik.name
|
||||
expect(response.body).to match rubrik.name
|
||||
expect(response.body).to match intern_neuigkeit.rubrik.name
|
||||
expect(response.body).to match neuigkeit.rubrik.name
|
||||
end
|
||||
end
|
||||
it "shows datum in response" do
|
||||
@@ -71,24 +72,15 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
|
||||
describe "GET#edit" do
|
||||
let(:action) { get :edit, {id: neuigkeit.id, rubrik_id: neuigkeit.rubrik.id}}
|
||||
include_examples "it is restricted"
|
||||
it_behaves_like "it assigns object"
|
||||
it_behaves_like "it assigns persisted object"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it is success"
|
||||
end
|
||||
it_behaves_like "default edit action"
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
let(:action) { get :new, {rubrik_id: neuigkeit.rubrik.id}}
|
||||
include_examples "it assigns new object"
|
||||
include_examples "it is restricted"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it is success"
|
||||
end
|
||||
it_behaves_like "default new action"
|
||||
end
|
||||
|
||||
describe "GET add_calentry" do
|
||||
@@ -115,13 +107,70 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it "redirects to neuigkeit" do
|
||||
expect(action).to redirect_to(rubrik_neuigkeit_url(rubrik,neuigkeit))
|
||||
expect(action).to redirect_to(rubrik_neuigkeit_url(neuigkeit.rubrik,neuigkeit))
|
||||
end
|
||||
it "assignes unpublished neuigkeit" do
|
||||
action
|
||||
expect(assigns(:neuigkeit)).not_to be_published
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET publish" do
|
||||
let(:action) {get :publish, {id: neuigkeit.id, rubrik_id: neuigkeit.rubrik.id}}
|
||||
it_behaves_like "it is restricted"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it "redirects to neuigkeit" do
|
||||
expect(action).to redirect_to(rubrik_neuigkeit_url(neuigkeit.rubrik,neuigkeit))
|
||||
end
|
||||
it "assignes published neuigkeit" do
|
||||
action
|
||||
expect(assigns(:neuigkeit)).to be_published
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
describe "POST create" do
|
||||
let(:action) {post :create, {rubrik_id: neuigkeit.rubrik.id, neuigkeit: FactoryGirl.attributes_for(:neuigkeit)}}
|
||||
|
||||
it_behaves_like "it is restricted"
|
||||
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it is success"
|
||||
it "adds 1 Neuigkeit" do
|
||||
expect{action}.to change { Neuigkeit.count}.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
let(:action) {put :update, {id: neuigkeit.id, rubrik_id: neuigkeit.rubrik.id}}
|
||||
it_behaves_like "it is a restricted action"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it assigns persisted object"
|
||||
it "redirects to neuigkeit" do
|
||||
expect(action).to redirect_to rubrik_neuigkeit_url(neuigkeit.rubrik, neuigkeit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
pending "destroy"
|
||||
pending "load_toolbar_elements"
|
||||
|
||||
|
||||
pending "publish_to_facebook"
|
||||
pending "mail_to_fet"
|
||||
pending "mail_preview"
|
||||
pending "newsletter_preview"
|
||||
pending "find_link"
|
||||
pending "create_link"
|
||||
pending "delete_link"
|
||||
|
||||
|
||||
end
|
||||
|
||||
36
spec/controllers/shared_examples/default_actions.rb
Normal file
36
spec/controllers/shared_examples/default_actions.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
shared_examples "public show action" do
|
||||
end
|
||||
|
||||
shared_examples "it is a restricted action" do
|
||||
it_behaves_like "it is restricted"
|
||||
it_behaves_like "it assigns object"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it "redirects to object url" do
|
||||
expect(action).to redirect_to(object_url)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples "default edit action" do
|
||||
it_behaves_like "it is restricted"
|
||||
it_behaves_like "it assigns object"
|
||||
it_behaves_like "it assigns persisted object"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it is success"
|
||||
end
|
||||
end
|
||||
shared_examples "default new action" do
|
||||
include_examples "it assigns new object"
|
||||
include_examples "it is restricted"
|
||||
context "with fet user" do
|
||||
with_fet_user
|
||||
it_behaves_like "it is success"
|
||||
it_behaves_like "it assigns new object"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,10 +9,11 @@ FactoryGirl.define do
|
||||
end
|
||||
trait :fetuser do
|
||||
after(:create) do |user|
|
||||
user.after_create {|u| u.add_role("fetuser")}
|
||||
user.add_role("fetuser")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user