diff options
-rw-r--r-- | app/controllers/route_elements_controller.rb | 41 | ||||
-rw-r--r-- | app/helpers/route_elements_helper.rb | 2 | ||||
-rw-r--r-- | app/models/route_element.rb | 5 | ||||
-rw-r--r-- | app/views/route_elements/_form.html.haml | 7 | ||||
-rw-r--r-- | app/views/route_elements/_form_core.html.haml | 9 | ||||
-rw-r--r-- | app/views/route_elements/_index_core.html.haml | 23 | ||||
-rw-r--r-- | app/views/route_elements/edit.html.haml | 3 | ||||
-rw-r--r-- | app/views/route_elements/index.html.haml | 6 | ||||
-rw-r--r-- | app/views/route_elements/new.html.haml | 3 | ||||
-rw-r--r-- | app/views/route_elements/show.html.haml | 28 | ||||
-rw-r--r-- | config/locales/views/route_elements/de.yml | 75 | ||||
-rw-r--r-- | config/locales/views/route_elements/en.yml | 75 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | db/migrate/20130116133433_create_route_elements.rb | 19 | ||||
-rw-r--r-- | test/functional/route_elements_controller_test.rb | 49 | ||||
-rw-r--r-- | test/unit/route_element_test.rb | 7 |
16 files changed, 354 insertions, 0 deletions
diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb new file mode 100644 index 0000000..595a20d --- /dev/null +++ b/app/controllers/route_elements_controller.rb @@ -0,0 +1,41 @@ +class RouteElementsController < ApplicationController + def index + @route_elements = RouteElement.all + end + + def show + @route_element = RouteElement.find(params[:id]) + end + + def new + @route_element = RouteElement.new + end + + def create + @route_element = RouteElement.new(params[:route_element]) + if @route_element.save + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_created') + else + render :new + end + end + + def edit + @route_element = RouteElement.find(params[:id]) + end + + def update + @route_element = RouteElement.find(params[:id]) + if @route_element.update_attributes(params[:route_element]) + redirect_to @route_element, :notice => t('route_elements.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @route_element = RouteElement.find(params[:id]) + @route_element.destroy + redirect_to route_elements_url, :notice => t('route_elements.controller.successfuly_destroyed') + end +end diff --git a/app/helpers/route_elements_helper.rb b/app/helpers/route_elements_helper.rb new file mode 100644 index 0000000..4262a50 --- /dev/null +++ b/app/helpers/route_elements_helper.rb @@ -0,0 +1,2 @@ +module RouteElementsHelper +end diff --git a/app/models/route_element.rb b/app/models/route_element.rb new file mode 100644 index 0000000..e845f24 --- /dev/null +++ b/app/models/route_element.rb @@ -0,0 +1,5 @@ +class RouteElement < ActiveRecord::Base + attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position + + belongs_to :call_route +end diff --git a/app/views/route_elements/_form.html.haml b/app/views/route_elements/_form.html.haml new file mode 100644 index 0000000..cfa4c6b --- /dev/null +++ b/app/views/route_elements/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for(@route_element) do |f| + = f.error_notification + + = render "form_core", :f => f + + .actions + = f.button :submit, conditional_t('route_elements.form.submit')
\ No newline at end of file diff --git a/app/views/route_elements/_form_core.html.haml b/app/views/route_elements/_form_core.html.haml new file mode 100644 index 0000000..7697cb0 --- /dev/null +++ b/app/views/route_elements/_form_core.html.haml @@ -0,0 +1,9 @@ +.inputs + = f.input :call_route_id, :label => t('route_elements.form.call_route_id.label'), :hint => conditional_hint('route_elements.form.call_route_id.hint') + = f.input :var_in, :label => t('route_elements.form.var_in.label'), :hint => conditional_hint('route_elements.form.var_in.hint') + = f.input :var_out, :label => t('route_elements.form.var_out.label'), :hint => conditional_hint('route_elements.form.var_out.hint') + = f.input :pattern, :label => t('route_elements.form.pattern.label'), :hint => conditional_hint('route_elements.form.pattern.hint') + = f.input :replacement, :label => t('route_elements.form.replacement.label'), :hint => conditional_hint('route_elements.form.replacement.hint') + = f.input :action, :label => t('route_elements.form.action.label'), :hint => conditional_hint('route_elements.form.action.hint') + = f.input :mandatory, :label => t('route_elements.form.mandatory.label'), :hint => conditional_hint('route_elements.form.mandatory.hint') + = f.input :position, :label => t('route_elements.form.position.label'), :hint => conditional_hint('route_elements.form.position.hint') diff --git a/app/views/route_elements/_index_core.html.haml b/app/views/route_elements/_index_core.html.haml new file mode 100644 index 0000000..63665fd --- /dev/null +++ b/app/views/route_elements/_index_core.html.haml @@ -0,0 +1,23 @@ +%table + %tr + %th= t('route_elements.index.call_route_id') + %th= t('route_elements.index.var_in') + %th= t('route_elements.index.var_out') + %th= t('route_elements.index.pattern') + %th= t('route_elements.index.replacement') + %th= t('route_elements.index.action') + %th= t('route_elements.index.mandatory') + %th= t('route_elements.index.position') + + - reset_cycle + - for route_element in route_elements + %tr{:class => cycle('odd', 'even')} + %td= route_element.call_route_id + %td= route_element.var_in + %td= route_element.var_out + %td= route_element.pattern + %td= route_element.replacement + %td= route_element.action + %td= route_element.mandatory + %td= route_element.position + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => route_element}
\ No newline at end of file diff --git a/app/views/route_elements/edit.html.haml b/app/views/route_elements/edit.html.haml new file mode 100644 index 0000000..770eb6c --- /dev/null +++ b/app/views/route_elements/edit.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.edit.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/route_elements/index.html.haml b/app/views/route_elements/index.html.haml new file mode 100644 index 0000000..b05236b --- /dev/null +++ b/app/views/route_elements/index.html.haml @@ -0,0 +1,6 @@ +- title t("route_elements.index.page_title") + +- if @route_elements && @route_elements.count > 0 + = render "index_core", :route_elements => @route_elements + += render :partial => 'shared/create_link', :locals => {:child_class => RouteElement}
\ No newline at end of file diff --git a/app/views/route_elements/new.html.haml b/app/views/route_elements/new.html.haml new file mode 100644 index 0000000..903e808 --- /dev/null +++ b/app/views/route_elements/new.html.haml @@ -0,0 +1,3 @@ +- title t("route_elements.new.page_title") + += render "form"
\ No newline at end of file diff --git a/app/views/route_elements/show.html.haml b/app/views/route_elements/show.html.haml new file mode 100644 index 0000000..a439353 --- /dev/null +++ b/app/views/route_elements/show.html.haml @@ -0,0 +1,28 @@ +- title t("route_elements.show.page_title") + +%p + %strong= t('route_elements.show.call_route_id') + ":" + = @route_element.call_route_id +%p + %strong= t('route_elements.show.var_in') + ":" + = @route_element.var_in +%p + %strong= t('route_elements.show.var_out') + ":" + = @route_element.var_out +%p + %strong= t('route_elements.show.pattern') + ":" + = @route_element.pattern +%p + %strong= t('route_elements.show.replacement') + ":" + = @route_element.replacement +%p + %strong= t('route_elements.show.action') + ":" + = @route_element.action +%p + %strong= t('route_elements.show.mandatory') + ":" + = @route_element.mandatory +%p + %strong= t('route_elements.show.position') + ":" + = @route_element.position + += render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @route_element }
\ No newline at end of file diff --git a/config/locales/views/route_elements/de.yml b/config/locales/views/route_elements/de.yml new file mode 100644 index 0000000..d2c6c39 --- /dev/null +++ b/config/locales/views/route_elements/de.yml @@ -0,0 +1,75 @@ +de: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Route element wurde angelegt.' + successfuly_updated: 'Route element wurde aktualisiert.' + successfuly_destroyed: 'Route element wurde gelöscht.' + index: + page_title: 'Übersicht von Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Route element' + destroy: 'Löschen' + edit: 'Bearbeiten' + show: 'Anzeigen' + create: 'Neu anlegen' + create_for: 'Route element neu anlegen für %{resource}' + show: + page_title: 'Route element bearbeiten' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Sind Sie sicher, dass die dieses Element löschen möchten?' + destroy: 'Löschen' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + new: + page_title: 'Route element neu anlegen' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: + page_title: 'Route element bearbeiten' + actions: + back_to_list: 'Zurück zur Übersicht' + edit: 'Bearbeiten' + view_all: 'Alle anzeigen' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Absenden'
\ No newline at end of file diff --git a/config/locales/views/route_elements/en.yml b/config/locales/views/route_elements/en.yml new file mode 100644 index 0000000..1340309 --- /dev/null +++ b/config/locales/views/route_elements/en.yml @@ -0,0 +1,75 @@ +en: + route_elements: + name: 'Route element' + controller: + successfuly_created: 'Successfully created Route element.' + successfuly_updated: 'Successfully updated Route element.' + successfuly_destroyed: 'Successfully destroyed Route element.' + index: + page_title: 'Listing Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this Route element?' + destroy: 'Delete' + edit: 'Edit' + show: 'View' + create: 'New' + create_for: 'New Route element for %{resource}' + show: + page_title: 'Show Route element' + call_route_id: 'Call route' + var_in: 'Var in' + var_out: 'Var out' + pattern: 'Pattern' + replacement: 'Replacement' + action: 'Action' + mandatory: 'Mandatory' + position: 'Position' + actions: + confirm: 'Are you sure you want to delete this element?' + destroy: 'Delete' + edit: 'Edit' + view_all: 'View All' + new: + page_title: 'New Route element' + actions: + back_to_list: 'Back to Index' + edit: + page_title: 'Editing Route element' + actions: + back_to_list: 'Back to Index' + edit: 'Edit' + view_all: 'View All' + form: + call_route_id: + label: 'Call route' + hint: '' + var_in: + label: 'Var in' + hint: '' + var_out: + label: 'Var out' + hint: '' + pattern: + label: 'Pattern' + hint: '' + replacement: + label: 'Replacement' + hint: '' + action: + label: 'Action' + hint: '' + mandatory: + label: 'Mandatory' + hint: '' + position: + label: 'Position' + hint: '' + button: 'Submit'
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2834d69..3874170 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Gemeinschaft42c::Application.routes.draw do + resources :route_elements + resources :call_routes resources :gateways do diff --git a/db/migrate/20130116133433_create_route_elements.rb b/db/migrate/20130116133433_create_route_elements.rb new file mode 100644 index 0000000..72f6894 --- /dev/null +++ b/db/migrate/20130116133433_create_route_elements.rb @@ -0,0 +1,19 @@ +class CreateRouteElements < ActiveRecord::Migration + def self.up + create_table :route_elements do |t| + t.integer :call_route_id + t.string :var_in + t.string :var_out + t.string :pattern + t.string :replacement + t.string :action + t.boolean :mandatory + t.integer :position + t.timestamps + end + end + + def self.down + drop_table :route_elements + end +end diff --git a/test/functional/route_elements_controller_test.rb b/test/functional/route_elements_controller_test.rb new file mode 100644 index 0000000..3d7afaa --- /dev/null +++ b/test/functional/route_elements_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class RouteElementsControllerTest < ActionController::TestCase + setup do + @route_element = route_elements(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:route_elements) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create route_element" do + assert_difference('RouteElement.count') do + post :create, route_element: @route_element.attributes + end + + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should show route_element" do + get :show, id: @route_element.to_param + assert_response :success + end + + test "should get edit" do + get :edit, id: @route_element.to_param + assert_response :success + end + + test "should update route_element" do + put :update, id: @route_element.to_param, route_element: @route_element.attributes + assert_redirected_to route_element_path(assigns(:route_element)) + end + + test "should destroy route_element" do + assert_difference('RouteElement.count', -1) do + delete :destroy, id: @route_element.to_param + end + + assert_redirected_to route_elements_path + end +end diff --git a/test/unit/route_element_test.rb b/test/unit/route_element_test.rb new file mode 100644 index 0000000..807a4ca --- /dev/null +++ b/test/unit/route_element_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RouteElementTest < ActiveSupport::TestCase + def test_should_be_valid + assert RouteElement.new.valid? + end +end |