summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/gs_parameters_controller.rb66
-rw-r--r--app/models/gs_parameter.rb2
-rw-r--r--app/views/gs_parameters/_form.html.erb15
-rw-r--r--app/views/gs_parameters/_form.html.haml7
-rw-r--r--app/views/gs_parameters/_form_core.html.haml6
-rw-r--r--app/views/gs_parameters/_index_core.html.haml17
-rw-r--r--app/views/gs_parameters/edit.html.erb6
-rw-r--r--app/views/gs_parameters/edit.html.haml3
-rw-r--r--app/views/gs_parameters/index.html.erb29
-rw-r--r--app/views/gs_parameters/index.html.haml6
-rw-r--r--app/views/gs_parameters/new.html.erb5
-rw-r--r--app/views/gs_parameters/new.html.haml3
-rw-r--r--app/views/gs_parameters/show.html.erb25
-rw-r--r--app/views/gs_parameters/show.html.haml19
-rw-r--r--config/initializers/gemeinschaft_parameters.rb6
-rw-r--r--config/locales/views/gs_parameters/de.yml60
-rw-r--r--config/locales/views/gs_parameters/en.yml60
-rw-r--r--db/migrate/20130105120126_create_gs_parameters.rb (renamed from db/migrate/20130105093021_create_gs_parameters.rb)10
-rw-r--r--db/migrate/20130105120353_populate_gs_parameter_with_defaults.rb (renamed from db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb)0
-rw-r--r--test/factories/gs_parameters.rb10
-rw-r--r--test/functional/gs_parameters_controller_test.rb8
-rw-r--r--test/unit/gs_parameter_test.rb6
-rw-r--r--test/unit/helpers/gs_parameters_helper_test.rb4
23 files changed, 212 insertions, 161 deletions
diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb
index d6a92c6..be3378e 100644
--- a/app/controllers/gs_parameters_controller.rb
+++ b/app/controllers/gs_parameters_controller.rb
@@ -1,83 +1,41 @@
class GsParametersController < ApplicationController
- # GET /gs_parameters
- # GET /gs_parameters.json
def index
@gs_parameters = GsParameter.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @gs_parameters }
- end
end
- # GET /gs_parameters/1
- # GET /gs_parameters/1.json
def show
@gs_parameter = GsParameter.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @gs_parameter }
- end
end
- # GET /gs_parameters/new
- # GET /gs_parameters/new.json
def new
@gs_parameter = GsParameter.new
+ end
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @gs_parameter }
+ def create
+ @gs_parameter = GsParameter.new(params[:gs_parameter])
+ if @gs_parameter.save
+ redirect_to @gs_parameter, :notice => t('gs_parameters.controller.successfuly_created')
+ else
+ render :new
end
end
- # GET /gs_parameters/1/edit
def edit
@gs_parameter = GsParameter.find(params[:id])
end
- # POST /gs_parameters
- # POST /gs_parameters.json
- def create
- @gs_parameter = GsParameter.new(params[:gs_parameter])
-
- respond_to do |format|
- if @gs_parameter.save
- format.html { redirect_to @gs_parameter, notice: 'Gs parameter was successfully created.' }
- format.json { render json: @gs_parameter, status: :created, location: @gs_parameter }
- else
- format.html { render action: "new" }
- format.json { render json: @gs_parameter.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /gs_parameters/1
- # PUT /gs_parameters/1.json
def update
@gs_parameter = GsParameter.find(params[:id])
-
- respond_to do |format|
- if @gs_parameter.update_attributes(params[:gs_parameter])
- format.html { redirect_to @gs_parameter, notice: 'Gs parameter was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @gs_parameter.errors, status: :unprocessable_entity }
- end
+ if @gs_parameter.update_attributes(params[:gs_parameter])
+ redirect_to @gs_parameter, :notice => t('gs_parameters.controller.successfuly_updated')
+ else
+ render :edit
end
end
- # DELETE /gs_parameters/1
- # DELETE /gs_parameters/1.json
def destroy
@gs_parameter = GsParameter.find(params[:id])
@gs_parameter.destroy
-
- respond_to do |format|
- format.html { redirect_to gs_parameters_url }
- format.json { head :no_content }
- end
+ redirect_to gs_parameters_url, :notice => t('gs_parameters.controller.successfuly_destroyed')
end
end
diff --git a/app/models/gs_parameter.rb b/app/models/gs_parameter.rb
index aac10b0..8e30583 100644
--- a/app/models/gs_parameter.rb
+++ b/app/models/gs_parameter.rb
@@ -1,4 +1,6 @@
class GsParameter < ActiveRecord::Base
+ attr_accessible :name, :section, :value, :class_type, :description
+
validates :name,
:presence => true,
:uniqueness => true
diff --git a/app/views/gs_parameters/_form.html.erb b/app/views/gs_parameters/_form.html.erb
deleted file mode 100644
index e559bcc..0000000
--- a/app/views/gs_parameters/_form.html.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-<%= simple_form_for(@gs_parameter) do |f| %>
- <%= f.error_notification %>
-
- <div class="inputs">
- <%= f.input :name, :autofocus => true %>
- <%= f.input :section %>
- <%= f.input :value %>
- <%= f.input :class_type %>
-
- </div>
-
- <div class="actions">
- <%= f.button :submit %>
- </div>
-<% end %>
diff --git a/app/views/gs_parameters/_form.html.haml b/app/views/gs_parameters/_form.html.haml
new file mode 100644
index 0000000..ea69e95
--- /dev/null
+++ b/app/views/gs_parameters/_form.html.haml
@@ -0,0 +1,7 @@
+= simple_form_for(@gs_parameter) do |f|
+ = f.error_notification
+
+ = render "form_core", :f => f
+
+ .actions
+ = f.button :submit, conditional_t('gs_parameters.form.submit') \ No newline at end of file
diff --git a/app/views/gs_parameters/_form_core.html.haml b/app/views/gs_parameters/_form_core.html.haml
new file mode 100644
index 0000000..ebb5f2d
--- /dev/null
+++ b/app/views/gs_parameters/_form_core.html.haml
@@ -0,0 +1,6 @@
+.inputs
+ = f.input :name, :label => t('gs_parameters.form.name.label'), :hint => conditional_hint('gs_parameters.form.name.hint')
+ = f.input :section, :label => t('gs_parameters.form.section.label'), :hint => conditional_hint('gs_parameters.form.section.hint')
+ = f.input :value, :label => t('gs_parameters.form.value.label'), :hint => conditional_hint('gs_parameters.form.value.hint')
+ = f.input :class_type, :label => t('gs_parameters.form.class_type.label'), :hint => conditional_hint('gs_parameters.form.class_type.hint')
+ = f.input :description, :label => t('gs_parameters.form.description.label'), :hint => conditional_hint('gs_parameters.form.description.hint')
diff --git a/app/views/gs_parameters/_index_core.html.haml b/app/views/gs_parameters/_index_core.html.haml
new file mode 100644
index 0000000..cc6fdd9
--- /dev/null
+++ b/app/views/gs_parameters/_index_core.html.haml
@@ -0,0 +1,17 @@
+%table
+ %tr
+ %th= t('gs_parameters.index.name')
+ %th= t('gs_parameters.index.section')
+ %th= t('gs_parameters.index.value')
+ %th= t('gs_parameters.index.class_type')
+ %th= t('gs_parameters.index.description')
+
+ - reset_cycle
+ - for gs_parameter in gs_parameters
+ %tr{:class => cycle('odd', 'even')}
+ %td= gs_parameter.name
+ %td= gs_parameter.section
+ %td= gs_parameter.value
+ %td= gs_parameter.class_type
+ %td= gs_parameter.description
+ =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gs_parameter} \ No newline at end of file
diff --git a/app/views/gs_parameters/edit.html.erb b/app/views/gs_parameters/edit.html.erb
deleted file mode 100644
index 6938a40..0000000
--- a/app/views/gs_parameters/edit.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>Editing gs_parameter</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @gs_parameter %> |
-<%= link_to 'Back', gs_parameters_path %>
diff --git a/app/views/gs_parameters/edit.html.haml b/app/views/gs_parameters/edit.html.haml
new file mode 100644
index 0000000..7c24234
--- /dev/null
+++ b/app/views/gs_parameters/edit.html.haml
@@ -0,0 +1,3 @@
+- title t("gs_parameters.edit.page_title")
+
+= render "form" \ No newline at end of file
diff --git a/app/views/gs_parameters/index.html.erb b/app/views/gs_parameters/index.html.erb
deleted file mode 100644
index dee6838..0000000
--- a/app/views/gs_parameters/index.html.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-<h1>Listing gs_parameters</h1>
-
-<table>
- <tr>
- <th>Name</th>
- <th>Section</th>
- <th>Value</th>
- <th>Class type</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @gs_parameters.each do |gs_parameter| %>
- <tr>
- <td><%= gs_parameter.name %></td>
- <td><%= gs_parameter.section %></td>
- <td><%= gs_parameter.value %></td>
- <td><%= gs_parameter.class_type %></td>
- <td><%= link_to 'Show', gs_parameter %></td>
- <td><%= link_to 'Edit', edit_gs_parameter_path(gs_parameter) %></td>
- <td><%= link_to 'Destroy', gs_parameter, confirm: 'Are you sure?', method: :delete %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New Gs parameter', new_gs_parameter_path %>
diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml
new file mode 100644
index 0000000..4c9ac84
--- /dev/null
+++ b/app/views/gs_parameters/index.html.haml
@@ -0,0 +1,6 @@
+- title t("gs_parameters.index.page_title")
+
+- if @gs_parameters && @gs_parameters.count > 0
+ = render "index_core", :gs_parameters => @gs_parameters
+
+= render :partial => 'shared/create_link', :locals => {:child_class => GsParameter} \ No newline at end of file
diff --git a/app/views/gs_parameters/new.html.erb b/app/views/gs_parameters/new.html.erb
deleted file mode 100644
index a357e2e..0000000
--- a/app/views/gs_parameters/new.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-<h1>New gs_parameter</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', gs_parameters_path %>
diff --git a/app/views/gs_parameters/new.html.haml b/app/views/gs_parameters/new.html.haml
new file mode 100644
index 0000000..845acc2
--- /dev/null
+++ b/app/views/gs_parameters/new.html.haml
@@ -0,0 +1,3 @@
+- title t("gs_parameters.new.page_title")
+
+= render "form" \ No newline at end of file
diff --git a/app/views/gs_parameters/show.html.erb b/app/views/gs_parameters/show.html.erb
deleted file mode 100644
index 1f03542..0000000
--- a/app/views/gs_parameters/show.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>Name:</b>
- <%= @gs_parameter.name %>
-</p>
-
-<p>
- <b>Section:</b>
- <%= @gs_parameter.section %>
-</p>
-
-<p>
- <b>Value:</b>
- <%= @gs_parameter.value %>
-</p>
-
-<p>
- <b>Class type:</b>
- <%= @gs_parameter.class_type %>
-</p>
-
-
-<%= link_to 'Edit', edit_gs_parameter_path(@gs_parameter) %> |
-<%= link_to 'Back', gs_parameters_path %>
diff --git a/app/views/gs_parameters/show.html.haml b/app/views/gs_parameters/show.html.haml
new file mode 100644
index 0000000..185641d
--- /dev/null
+++ b/app/views/gs_parameters/show.html.haml
@@ -0,0 +1,19 @@
+- title t("gs_parameters.show.page_title")
+
+%p
+ %strong= t('gs_parameters.show.name') + ":"
+ = @gs_parameter.name
+%p
+ %strong= t('gs_parameters.show.section') + ":"
+ = @gs_parameter.section
+%p
+ %strong= t('gs_parameters.show.value') + ":"
+ = @gs_parameter.value
+%p
+ %strong= t('gs_parameters.show.class_type') + ":"
+ = @gs_parameter.class_type
+%p
+ %strong= t('gs_parameters.show.description') + ":"
+ = @gs_parameter.description
+
+= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gs_parameter } \ No newline at end of file
diff --git a/config/initializers/gemeinschaft_parameters.rb b/config/initializers/gemeinschaft_parameters.rb
index dd6b2eb..844ff32 100644
--- a/config/initializers/gemeinschaft_parameters.rb
+++ b/config/initializers/gemeinschaft_parameters.rb
@@ -1,5 +1,5 @@
# Set some constants.
-GsParameter.all.each do |gs_parameter|
- gs_parameter.generate_constant
-end \ No newline at end of file
+# GsParameter.all.each do |gs_parameter|
+# gs_parameter.generate_constant
+# end
diff --git a/config/locales/views/gs_parameters/de.yml b/config/locales/views/gs_parameters/de.yml
new file mode 100644
index 0000000..f6935b8
--- /dev/null
+++ b/config/locales/views/gs_parameters/de.yml
@@ -0,0 +1,60 @@
+de:
+ gs_parameters:
+ name: 'Gsparameter'
+ controller:
+ successfuly_created: 'Gsparameter wurde angelegt.'
+ successfuly_updated: 'Gsparameter wurde aktualisiert.'
+ successfuly_destroyed: 'Gsparameter wurde gelöscht.'
+ index:
+ page_title: 'Übersicht von Gsparameter'
+ name: 'Name'
+ section: 'Section'
+ value: 'Value'
+ class_type: 'Class type'
+ description: 'Description'
+ actions:
+ confirm: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Gsparameter'
+ destroy: 'Löschen'
+ edit: 'Bearbeiten'
+ show: 'Anzeigen'
+ create: 'Neu anlegen'
+ create_for: 'Gsparameter neu anlegen für %{resource}'
+ show:
+ page_title: 'Gsparameter bearbeiten'
+ name: 'Name'
+ section: 'Section'
+ value: 'Value'
+ class_type: 'Class type'
+ description: 'Description'
+ 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: 'Gsparameter neu anlegen'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit:
+ page_title: 'Gsparameter bearbeiten'
+ actions:
+ back_to_list: 'Zurück zur Übersicht'
+ edit: 'Bearbeiten'
+ view_all: 'Alle anzeigen'
+ form:
+ name:
+ label: 'Name'
+ hint: ''
+ section:
+ label: 'Section'
+ hint: ''
+ value:
+ label: 'Value'
+ hint: ''
+ class_type:
+ label: 'Class type'
+ hint: ''
+ description:
+ label: 'Description'
+ hint: ''
+ button: 'Absenden' \ No newline at end of file
diff --git a/config/locales/views/gs_parameters/en.yml b/config/locales/views/gs_parameters/en.yml
new file mode 100644
index 0000000..040a6b8
--- /dev/null
+++ b/config/locales/views/gs_parameters/en.yml
@@ -0,0 +1,60 @@
+en:
+ gs_parameters:
+ name: 'Gsparameter'
+ controller:
+ successfuly_created: 'Successfully created Gsparameter.'
+ successfuly_updated: 'Successfully updated Gsparameter.'
+ successfuly_destroyed: 'Successfully destroyed Gsparameter.'
+ index:
+ page_title: 'Listing Gsparameter'
+ name: 'Name'
+ section: 'Section'
+ value: 'Value'
+ class_type: 'Class type'
+ description: 'Description'
+ actions:
+ confirm: 'Are you sure you want to delete this Gsparameter?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ show: 'View'
+ create: 'New'
+ create_for: 'New Gsparameter for %{resource}'
+ show:
+ page_title: 'Show Gsparameter'
+ name: 'Name'
+ section: 'Section'
+ value: 'Value'
+ class_type: 'Class type'
+ description: 'Description'
+ actions:
+ confirm: 'Are you sure you want to delete this element?'
+ destroy: 'Delete'
+ edit: 'Edit'
+ view_all: 'View All'
+ new:
+ page_title: 'New Gsparameter'
+ actions:
+ back_to_list: 'Back to Index'
+ edit:
+ page_title: 'Editing Gsparameter'
+ actions:
+ back_to_list: 'Back to Index'
+ edit: 'Edit'
+ view_all: 'View All'
+ form:
+ name:
+ label: 'Name'
+ hint: ''
+ section:
+ label: 'Section'
+ hint: ''
+ value:
+ label: 'Value'
+ hint: ''
+ class_type:
+ label: 'Class type'
+ hint: ''
+ description:
+ label: 'Description'
+ hint: ''
+ button: 'Submit' \ No newline at end of file
diff --git a/db/migrate/20130105093021_create_gs_parameters.rb b/db/migrate/20130105120126_create_gs_parameters.rb
index e1ea2b2..b8b915b 100644
--- a/db/migrate/20130105093021_create_gs_parameters.rb
+++ b/db/migrate/20130105120126_create_gs_parameters.rb
@@ -1,12 +1,16 @@
class CreateGsParameters < ActiveRecord::Migration
- def change
+ def self.up
create_table :gs_parameters do |t|
t.string :name
t.string :section
- t.string :value
+ t.text :value
t.string :class_type
-
+ t.string :description
t.timestamps
end
end
+
+ def self.down
+ drop_table :gs_parameters
+ end
end
diff --git a/db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb b/db/migrate/20130105120353_populate_gs_parameter_with_defaults.rb
index a4c9358..a4c9358 100644
--- a/db/migrate/20130105093128_populate_gs_parameter_with_defaults.rb
+++ b/db/migrate/20130105120353_populate_gs_parameter_with_defaults.rb
diff --git a/test/factories/gs_parameters.rb b/test/factories/gs_parameters.rb
deleted file mode 100644
index cc588e1..0000000
--- a/test/factories/gs_parameters.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# Read about factories at https://github.com/thoughtbot/factory_girl
-
-FactoryGirl.define do
- factory :gs_parameter do
- name "MyString"
- section "MyString"
- value "MyString"
- class_type "MyString"
- end
-end
diff --git a/test/functional/gs_parameters_controller_test.rb b/test/functional/gs_parameters_controller_test.rb
index 2436a69..a0e498a 100644
--- a/test/functional/gs_parameters_controller_test.rb
+++ b/test/functional/gs_parameters_controller_test.rb
@@ -25,23 +25,23 @@ class GsParametersControllerTest < ActionController::TestCase
end
test "should show gs_parameter" do
- get :show, id: @gs_parameter
+ get :show, id: @gs_parameter.to_param
assert_response :success
end
test "should get edit" do
- get :edit, id: @gs_parameter
+ get :edit, id: @gs_parameter.to_param
assert_response :success
end
test "should update gs_parameter" do
- put :update, id: @gs_parameter, gs_parameter: @gs_parameter.attributes
+ put :update, id: @gs_parameter.to_param, gs_parameter: @gs_parameter.attributes
assert_redirected_to gs_parameter_path(assigns(:gs_parameter))
end
test "should destroy gs_parameter" do
assert_difference('GsParameter.count', -1) do
- delete :destroy, id: @gs_parameter
+ delete :destroy, id: @gs_parameter.to_param
end
assert_redirected_to gs_parameters_path
diff --git a/test/unit/gs_parameter_test.rb b/test/unit/gs_parameter_test.rb
index bc7768f..2e3793a 100644
--- a/test/unit/gs_parameter_test.rb
+++ b/test/unit/gs_parameter_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class GsParameterTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ def test_should_be_valid
+ assert GsParameter.new.valid?
+ end
end
diff --git a/test/unit/helpers/gs_parameters_helper_test.rb b/test/unit/helpers/gs_parameters_helper_test.rb
deleted file mode 100644
index d7653e0..0000000
--- a/test/unit/helpers/gs_parameters_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class GsParametersHelperTest < ActionView::TestCase
-end