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,6 +145,7 @@ end
|
|||||||
@calentries<< Calentry.new
|
@calentries<< Calentry.new
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_link
|
def find_link
|
||||||
@rubrik=@neuigkeit.rubrik
|
@rubrik=@neuigkeit.rubrik
|
||||||
if can?(:shownonpublic, Rubrik)
|
if can?(:shownonpublic, Rubrik)
|
||||||
@@ -156,6 +157,7 @@ end
|
|||||||
@calentries1=@neuigkeit.calentries
|
@calentries1=@neuigkeit.calentries
|
||||||
nlink_search = Neuigkeit::LINKTYPES.clone
|
nlink_search = Neuigkeit::LINKTYPES.clone
|
||||||
nlink_search.collect!{|t| t.constantize}
|
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
|
@results= Sunspot.search nlink_search do
|
||||||
fulltext params[:query]
|
fulltext params[:query]
|
||||||
@@ -168,6 +170,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_link
|
def create_link
|
||||||
@neuigkeit = Neuigkeit.find(params[:id])
|
@neuigkeit = Neuigkeit.find(params[:id])
|
||||||
|
|
||||||
@@ -178,6 +181,7 @@ end
|
|||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_link
|
def delete_link
|
||||||
@neuigkeit = Neuigkeit.find(params[:id])
|
@neuigkeit = Neuigkeit.find(params[:id])
|
||||||
@nlink = @neuigkeit.nlinks.find(params[:nlink_id])
|
@nlink = @neuigkeit.nlinks.find(params[:nlink_id])
|
||||||
@@ -187,6 +191,7 @@ end
|
|||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@neuigkeit = Neuigkeit.new(params[:neuigkeit])
|
@neuigkeit = Neuigkeit.new(params[:neuigkeit])
|
||||||
@neuigkeit.author=current_user
|
@neuigkeit.author=current_user
|
||||||
|
|||||||
@@ -2,22 +2,22 @@ production:
|
|||||||
solr:
|
solr:
|
||||||
hostname: localhost
|
hostname: localhost
|
||||||
port: 8080
|
port: 8080
|
||||||
log_level: WARNING
|
# log_level: WARNING
|
||||||
min_memory: 32M
|
# min_memory: 32M
|
||||||
max_memory: 1G
|
# max_memory: 1G
|
||||||
path: /solr-4.10.2/default #production #ollection1 #production
|
# path: /solr-4.10.2/default #production #ollection1 #production
|
||||||
# solr_home: solr
|
# solr_home: solr
|
||||||
# read_timeout: 2
|
# read_timeout: 2
|
||||||
# open_timeout: 0.5
|
# open_timeout: 0.5
|
||||||
|
|
||||||
development:
|
development:
|
||||||
solr:
|
solr:
|
||||||
hostname: triton-amp.local
|
hostname: localhost
|
||||||
port: 8080
|
port: 8983
|
||||||
log_level: INFO
|
log_level: INFO
|
||||||
path: /solr/mycore
|
path: /solr/fetsite_test
|
||||||
min_memory: 32M
|
# min_memory: 32M
|
||||||
max_memory: 1G
|
# max_memory: 1G
|
||||||
# solr:
|
# solr:
|
||||||
# hostname: localhost
|
# hostname: localhost
|
||||||
# port: 8983
|
# port: 8983
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
|||||||
let(:assigned_object_variable){neuigkeit}
|
let(:assigned_object_variable){neuigkeit}
|
||||||
|
|
||||||
#let(:allow_fet_user) {allow(@controller).to receive(:current_user).and_return(fet_user)}
|
#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
|
describe "GET #show" do
|
||||||
@@ -33,7 +34,7 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "denys access to unpublished news" do
|
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
|
get :show, {id: neuigkeit.id}, valid_session
|
||||||
expect(response).to have_http_status(302)
|
expect(response).to have_http_status(302)
|
||||||
end
|
end
|
||||||
@@ -51,17 +52,17 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
|||||||
expect(response.body).to match neuigkeit.name
|
expect(response.body).to match neuigkeit.name
|
||||||
end
|
end
|
||||||
it "has only links to external rubrik" do
|
it "has only links to external rubrik" do
|
||||||
get :show, {id: neuigkeit.id}, public_session
|
get :show, {id: neuigkeit.id}, valid_session
|
||||||
expect(response.body).to match rubrik.name
|
expect(response.body).to match neuigkeit.rubrik.name
|
||||||
expect(response.body).not_to match intern_rubrik.name
|
expect(response.body).not_to match intern_neuigkeit.rubrik.name
|
||||||
end
|
end
|
||||||
|
|
||||||
context "and fet user" do
|
context "and fet user" do
|
||||||
with_fet_user
|
with_fet_user
|
||||||
it "has all links to internal and external rubriken" do
|
it "has all links to internal and external rubriken" do
|
||||||
action
|
action
|
||||||
expect(response.body).to match intern_rubrik.name
|
expect(response.body).to match intern_neuigkeit.rubrik.name
|
||||||
expect(response.body).to match rubrik.name
|
expect(response.body).to match neuigkeit.rubrik.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it "shows datum in response" do
|
it "shows datum in response" do
|
||||||
@@ -71,24 +72,15 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #edit" do
|
|
||||||
|
describe "GET#edit" do
|
||||||
let(:action) { get :edit, {id: neuigkeit.id, rubrik_id: neuigkeit.rubrik.id}}
|
let(:action) { get :edit, {id: neuigkeit.id, rubrik_id: neuigkeit.rubrik.id}}
|
||||||
include_examples "it is restricted"
|
it_behaves_like "default edit action"
|
||||||
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
|
end
|
||||||
|
|
||||||
describe "GET #new" do
|
describe "GET #new" do
|
||||||
let(:action) { get :new, {rubrik_id: neuigkeit.rubrik.id}}
|
let(:action) { get :new, {rubrik_id: neuigkeit.rubrik.id}}
|
||||||
include_examples "it assigns new object"
|
it_behaves_like "default new action"
|
||||||
include_examples "it is restricted"
|
|
||||||
context "with fet user" do
|
|
||||||
with_fet_user
|
|
||||||
it_behaves_like "it is success"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET add_calentry" do
|
describe "GET add_calentry" do
|
||||||
@@ -115,13 +107,70 @@ RSpec.describe NeuigkeitenController, :type => :controller do
|
|||||||
context "with fet user" do
|
context "with fet user" do
|
||||||
with_fet_user
|
with_fet_user
|
||||||
it "redirects to neuigkeit" do
|
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
|
end
|
||||||
it "assignes unpublished neuigkeit" do
|
it "assignes unpublished neuigkeit" do
|
||||||
action
|
action
|
||||||
expect(assigns(:neuigkeit)).not_to be_published
|
expect(assigns(:neuigkeit)).not_to be_published
|
||||||
end
|
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
|
||||||
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
|
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
|
end
|
||||||
trait :fetuser do
|
trait :fetuser do
|
||||||
after(:create) do |user|
|
after(:create) do |user|
|
||||||
user.after_create {|u| u.add_role("fetuser")}
|
user.add_role("fetuser")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user