champollion 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/assets/javascripts/champollion/application.js +15 -0
- data/app/assets/stylesheets/champollion/application.css +15 -0
- data/app/controllers/champollion/application_controller.rb +4 -0
- data/app/controllers/champollion/translations_controller.rb +65 -0
- data/app/helpers/champollion/application_helper.rb +4 -0
- data/app/models/champollion/translation.rb +27 -0
- data/app/views/champollion/translations/_form.html.erb +38 -0
- data/app/views/champollion/translations/edit.html.erb +6 -0
- data/app/views/champollion/translations/index.html.erb +31 -0
- data/app/views/champollion/translations/new.html.erb +5 -0
- data/app/views/champollion/translations/show.html.erb +28 -0
- data/app/views/layouts/champollion/application.html.erb +14 -0
- data/config/initializers/locale.rb +4 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20150417194342_create_translations.rb +13 -0
- data/db/migrate/20150504193440_create_versions.rb +13 -0
- data/lib/champollion.rb +4 -0
- data/lib/champollion/engine.rb +15 -0
- data/lib/champollion/version.rb +3 -0
- data/lib/tasks/champollion_tasks.rake +4 -0
- data/spec/controllers/champollion/translations_controller_spec.rb +153 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150504185150_create_translations.champollion.rb +14 -0
- data/spec/dummy/db/migrate/20150504193530_create_versions.champollion.rb +14 -0
- data/spec/dummy/db/schema.rb +37 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +126 -0
- data/spec/dummy/log/test.log +21518 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/translation.rb +7 -0
- data/spec/models/champollion/translation_spec.rb +51 -0
- data/spec/routing/champollion/translations_routing_spec.rb +39 -0
- data/spec/spec_helper.rb +17 -0
- metadata +249 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ebbcfd645ca35bd4e73e1d1766ff5dfecc0dc0b
|
4
|
+
data.tar.gz: acb3be8233db305fcf643c6bec654f6565edee92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2180a468f62df7bd00c0637783d28256e7a18778ca14030027f2d17898619f7c136233332d4af6c5f211acea0a5b0d602dbb309986a25cf9f8fa9c066eb9680f
|
7
|
+
data.tar.gz: e080ccc9da6294d779c04946013e932c503a9b5167faf38e5597bd6832f6ba8467f2a4273c1a9f036901070e8e336f6a895d41c1fc96bac218245dbed3a0a4b6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Razvan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Champollion'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
|
28
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
29
|
+
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
|
33
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
34
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
35
|
+
|
36
|
+
task :default => :spec
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_dependency "champollion/application_controller"
|
2
|
+
|
3
|
+
module Champollion
|
4
|
+
class TranslationsController < ApplicationController
|
5
|
+
before_action :set_translation, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /translations
|
8
|
+
def index
|
9
|
+
respond_to do |format|
|
10
|
+
format.html { @translations = Translation.all }
|
11
|
+
format.json { render json: Translation.all_translations.to_json }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /translations/1
|
16
|
+
def show
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /translations/new
|
20
|
+
def new
|
21
|
+
@translation = Translation.new
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /translations/1/edit
|
25
|
+
def edit
|
26
|
+
end
|
27
|
+
|
28
|
+
# POST /translations
|
29
|
+
def create
|
30
|
+
@translation = Translation.new(translation_params)
|
31
|
+
|
32
|
+
if @translation.save
|
33
|
+
redirect_to @translation, notice: 'Translation was successfully created.'
|
34
|
+
else
|
35
|
+
render :new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# PATCH/PUT /translations/1
|
40
|
+
def update
|
41
|
+
if @translation.update(translation_params)
|
42
|
+
redirect_to @translation, notice: 'Translation was successfully updated.'
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /translations/1
|
49
|
+
def destroy
|
50
|
+
@translation.destroy
|
51
|
+
redirect_to translations_url, notice: 'Translation was successfully destroyed.'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_translation
|
57
|
+
@translation = Translation.find(params[:id])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Only allow a trusted parameter "white list" through.
|
61
|
+
def translation_params
|
62
|
+
params.require(:translation).permit(:locale, :key, :value, :interpolations, :is_proc)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Champollion
|
2
|
+
class Translation < ActiveRecord::Base
|
3
|
+
self.table_name = "translations"
|
4
|
+
|
5
|
+
has_paper_trail
|
6
|
+
|
7
|
+
validates :locale, presence: true
|
8
|
+
validates :key, presence: true
|
9
|
+
validates :value, presence: true
|
10
|
+
|
11
|
+
def self.all_translations
|
12
|
+
# create empty hash for locales
|
13
|
+
translation_hash = Hash.new { |k,v| k[v] = {} }
|
14
|
+
|
15
|
+
# iterate through the translation records
|
16
|
+
all.each do |translation|
|
17
|
+
# get the key components
|
18
|
+
key_scopes = translation.key.split(".")
|
19
|
+
|
20
|
+
translation_hash[translation.locale.to_sym] ||= {}
|
21
|
+
translation_hash[translation.locale.to_sym].merge!(key_scopes.reverse.inject(translation.value) {|a,n| { n.to_sym => a}})
|
22
|
+
end
|
23
|
+
|
24
|
+
translation_hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<%= form_for(@translation) do |f| %>
|
2
|
+
<% if @translation.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@translation.errors.count, "error") %> prohibited this translation from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @translation.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :locale %><br>
|
16
|
+
<%= f.text_field :locale %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :key %><br>
|
20
|
+
<%= f.text_field :key %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :value %><br>
|
24
|
+
<%= f.text_area :value %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :interpolations %><br>
|
28
|
+
<%= f.text_field :interpolations %>
|
29
|
+
</div>
|
30
|
+
<div class="field">
|
31
|
+
<%= f.label :is_proc %><br>
|
32
|
+
<%= f.check_box :is_proc %>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div class="actions">
|
36
|
+
<%= f.submit %>
|
37
|
+
</div>
|
38
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Listing Translations</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Locale</th>
|
9
|
+
<th>Key</th>
|
10
|
+
<th>Value</th>
|
11
|
+
<th colspan="3"></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
14
|
+
|
15
|
+
<tbody>
|
16
|
+
<% @translations.each do |translation| %>
|
17
|
+
<tr>
|
18
|
+
<td><%= translation.locale %></td>
|
19
|
+
<td><%= translation.key %></td>
|
20
|
+
<td><%= translation.value %></td>
|
21
|
+
<td><%= link_to 'Show', translation %></td>
|
22
|
+
<td><%= link_to 'Edit', edit_translation_path(translation) %></td>
|
23
|
+
<td><%= link_to 'Destroy', translation, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<%= link_to 'New Translation', new_translation_path %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Locale:</strong>
|
5
|
+
<%= @translation.locale %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Key:</strong>
|
10
|
+
<%= @translation.key %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Value:</strong>
|
15
|
+
<%= @translation.value %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<h2>Versions</h2>
|
20
|
+
<ul>
|
21
|
+
<% @translation.versions.each do |version| %>
|
22
|
+
<li><%= version.event %> | <%= version.index %> @ <%= version.created_at %></li>
|
23
|
+
<% end %>
|
24
|
+
</ul>
|
25
|
+
</p>
|
26
|
+
|
27
|
+
<%= link_to 'Edit', edit_translation_path(@translation) %> |
|
28
|
+
<%= link_to 'Back', translations_path %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Champollion</title>
|
5
|
+
<%= stylesheet_link_tag "champollion/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "champollion/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateTranslations < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :translations do |t|
|
4
|
+
t.string :locale
|
5
|
+
t.string :key
|
6
|
+
t.text :value
|
7
|
+
t.text :interpolations
|
8
|
+
t.boolean :is_proc, default: false
|
9
|
+
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateVersions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :versions do |t|
|
4
|
+
t.string :item_type, :null => false
|
5
|
+
t.integer :item_id, :null => false
|
6
|
+
t.string :event, :null => false
|
7
|
+
t.string :whodunnit
|
8
|
+
t.text :object
|
9
|
+
t.datetime :created_at
|
10
|
+
end
|
11
|
+
add_index :versions, [:item_type, :item_id]
|
12
|
+
end
|
13
|
+
end
|
data/lib/champollion.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "paper_trail"
|
2
|
+
|
3
|
+
module Champollion
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace Champollion
|
6
|
+
|
7
|
+
config.generators do |g|
|
8
|
+
g.test_framework :rspec, :fixture => false
|
9
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
10
|
+
g.assets false
|
11
|
+
g.helper false
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Champollion
|
4
|
+
RSpec.describe TranslationsController, :type => :controller do
|
5
|
+
routes { Champollion::Engine.routes }
|
6
|
+
|
7
|
+
let(:valid_attributes) {
|
8
|
+
{
|
9
|
+
locale: :en,
|
10
|
+
key: 'home.button',
|
11
|
+
value: 'Hello'
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:invalid_attributes) {
|
16
|
+
{
|
17
|
+
locale: :en
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
describe "GET index" do
|
22
|
+
it "assigns all translations as @translations" do
|
23
|
+
translation = Translation.create! valid_attributes
|
24
|
+
get :index
|
25
|
+
expect(assigns(:translations)).to eq([translation])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns json array when format is json" do
|
29
|
+
Translation.create! valid_attributes
|
30
|
+
|
31
|
+
get :index, format: :json
|
32
|
+
expect(response).to be_success
|
33
|
+
|
34
|
+
body = JSON.parse(response.body)
|
35
|
+
expect(body).to include("en")
|
36
|
+
expect(body).to eq({"en" => {"home" => {"button" => "Hello"}}})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "GET show" do
|
41
|
+
it "assigns the requested translation as @translation" do
|
42
|
+
translation = Translation.create! valid_attributes
|
43
|
+
get :show, {:id => translation.to_param}
|
44
|
+
expect(assigns(:translation)).to eq(translation)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "GET new" do
|
49
|
+
it "assigns a new translation as @translation" do
|
50
|
+
get :new
|
51
|
+
expect(assigns(:translation)).to be_a_new(Translation)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "GET edit" do
|
56
|
+
it "assigns the requested translation as @translation" do
|
57
|
+
translation = Translation.create! valid_attributes
|
58
|
+
get :edit, {:id => translation.to_param}
|
59
|
+
expect(assigns(:translation)).to eq(translation)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "POST create" do
|
64
|
+
describe "with valid params" do
|
65
|
+
it "creates a new Translation" do
|
66
|
+
expect {
|
67
|
+
post :create, {:translation => valid_attributes}
|
68
|
+
}.to change(Translation, :count).by(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "assigns a newly created translation as @translation" do
|
72
|
+
post :create, {:translation => valid_attributes}
|
73
|
+
expect(assigns(:translation)).to be_a(Translation)
|
74
|
+
expect(assigns(:translation)).to be_persisted
|
75
|
+
end
|
76
|
+
|
77
|
+
it "redirects to the created translation" do
|
78
|
+
post :create, {:translation => valid_attributes}
|
79
|
+
expect(response).to redirect_to(Translation.last)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "with invalid params" do
|
84
|
+
it "assigns a newly created but unsaved translation as @translation" do
|
85
|
+
post :create, {:translation => invalid_attributes}
|
86
|
+
expect(assigns(:translation)).to be_a_new(Translation)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "PUT update" do
|
93
|
+
describe "with valid params" do
|
94
|
+
let(:new_attributes) {
|
95
|
+
{
|
96
|
+
locale: :en,
|
97
|
+
key: 'home.button',
|
98
|
+
value: 'New value'
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
it "updates the requested translation" do
|
103
|
+
translation = Translation.create! valid_attributes
|
104
|
+
put :update, {:id => translation.to_param, :translation => new_attributes}
|
105
|
+
translation.reload
|
106
|
+
expect(translation.value).to eq("New value")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "assigns the requested translation as @translation" do
|
110
|
+
translation = Translation.create! valid_attributes
|
111
|
+
put :update, {:id => translation.to_param, :translation => valid_attributes}
|
112
|
+
expect(assigns(:translation)).to eq(translation)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "redirects to the translation" do
|
116
|
+
translation = Translation.create! valid_attributes
|
117
|
+
put :update, {:id => translation.to_param, :translation => valid_attributes}
|
118
|
+
expect(response).to redirect_to(translation)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "with invalid params" do
|
123
|
+
it "assigns the translation as @translation" do
|
124
|
+
translation = Translation.create! valid_attributes
|
125
|
+
put :update, {:id => translation.to_param, :translation => invalid_attributes}
|
126
|
+
expect(assigns(:translation)).to eq(translation)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "re-renders the 'edit' translation" do
|
130
|
+
translation = Translation.create! valid_attributes
|
131
|
+
put :update, {:id => translation.to_param, :translation => invalid_attributes}
|
132
|
+
expect(response).to redirect_to(translation)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "DELETE destroy" do
|
138
|
+
it "destroys the requested translation" do
|
139
|
+
translation = Translation.create! valid_attributes
|
140
|
+
expect {
|
141
|
+
delete :destroy, {:id => translation.to_param}
|
142
|
+
}.to change(Translation, :count).by(-1)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "redirects to the translations list" do
|
146
|
+
translation = Translation.create! valid_attributes
|
147
|
+
delete :destroy, {:id => translation.to_param}
|
148
|
+
expect(response).to redirect_to(translations_url)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|