Skip to content

Commit

Permalink
Merge dev into 46_1.7_Additional_Information
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterCarl committed Nov 30, 2016
2 parents 73190ee + ab57e0a commit 130d6f3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -4,6 +4,13 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?

rescue_from CanCan::AccessDenied do |exception|
respond_to do |format|
format.json { head :forbidden }
format.html { redirect_to main_app.root_url, :alert => exception.message }
end
end

def index

end
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Expand Up @@ -21,6 +21,9 @@

de:
hello: "Willkommen beim Workshop-Portal"
unauthorized:
manage:
all: "Du bist nicht authorisiert diese Aktion auszuführen."
navbar:
home: "Start"
events: "Veranstaltungen"
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Expand Up @@ -21,6 +21,9 @@

en:
hello: "Welcome to the Workshop-Portal"
unauthorized:
manage:
all: "You are not authorized to take this action."
navbar:
home: "Home"
events: "Events"
Expand Down
9 changes: 9 additions & 0 deletions db/seeds.rb
Expand Up @@ -95,6 +95,15 @@
# Applicant's application letter
ApplicationLetter.find_or_create_by!(
motivation: "Ich würde sehr gerne an eurer Veranstaltung teilnehmen",
grade: 10,
experience: "Internet",
coding_skills: "HTML",
emergency_number: "01234567891",
vegeterian: false,
vegan: false,
allergic: false,
allergies: "",
status: nil,
user: applicant,
event: event
)
14 changes: 12 additions & 2 deletions spec/features/application_letters_spec.rb
Expand Up @@ -68,15 +68,25 @@
expect(ApplicationLetter.where(grade:"11")).to exist
end



it "displays help text for motivation textarea" do
login(:pupil)
visit new_application_letter_path(:event_id => @event.id, :locale => :de)

expect(page).to have_text(I18n.t 'application_letters.form.help_text_coding_skills')
end

%i[pupil tutor].each do |role|
it "shows an error if the site of another application letter is accessed by url" do
user = FactoryGirl.create(:user, role: role)
another_user = FactoryGirl.create(:user)
another_application = FactoryGirl.create(:application_letter, user: another_user)

visit application_letter_path(id: another_application.id)

expect(page).to have_text(I18n.t('unauthorized.manage.all'))
end
end

def login(role)

@event = FactoryGirl.create(:event)
Expand Down

0 comments on commit 130d6f3

Please sign in to comment.