Commit 8f3e3f7

mo khan <mo@mokhan.ca>
2015-02-16 15:31:41
move translation to en.yml
1 parent 1c4295a
app/controllers/application_controller.rb
@@ -8,4 +8,8 @@ class ApplicationController < ActionController::Base
   def log_in(user)
     session[:user_id] = user.id
   end
+
+  def translate(key)
+    I18n.translate("#{params[:controller]}.#{params[:action]}#{key}")
+  end
 end
app/controllers/registrations_controller.rb
@@ -1,6 +1,6 @@
 class RegistrationsController < ApplicationController
   layout "public"
-  
+
   def new
     @user = User.new
   end
@@ -9,8 +9,8 @@ class RegistrationsController < ApplicationController
     @user = User.new(secure_params)
     if @user.save
       log_in(@user)
-      UserMailer.registration_email(@user).deliver_later # TODO change adapter
-      flash[:notice] = "Thank you for registering. Welcome to Supply Crow."
+      UserMailer.registration_email(@user).deliver_later
+      flash[:notice] = translate(".success")
       redirect_to dashboard_path
     else
       flash.now[:error] = @user.errors.full_messages
config/locales/en.yml
@@ -29,6 +29,8 @@ en:
       terms_and_conditions_link: "Terms and Conditions of Use"
       register_button: "Register"
       login_link: "Already have an account?"
+    create:
+      success: "Thank you for registering. Welcome to Supply Crow."
   sessions:
     create:
       invalid_login: "Sorry, we cannot find that account."
config/i18n-tasks.yml
@@ -50,8 +50,9 @@ search:
     - app/
 
   ## Root for resolving relative keys (default)
-  # relative_roots:
-  #   - app/views
+  relative_roots:
+    - app/views
+    - app/controllers
 
   ## File.fnmatch patterns to exclude from search (default)
   # exclude: ["*.jpg", "*.png", "*.gif", "*.svg", "*.ico", "*.eot", "*.ttf", "*.woff", "*.pdf"]
spec/controllers/registrations_controller_spec.rb
@@ -44,9 +44,10 @@ describe RegistrationsController do
       it "does not display any errors" do
         expect(flash[:error]).to be_nil
       end
-      
+
       it "shows a flash alert" do
         expect(flash[:notice]).to_not be_empty
+        expect(flash[:notice]).to eql("Thank you for registering. Welcome to Supply Crow.")
       end
 
       it "sends a user registration email" do
.gitignore
@@ -13,4 +13,6 @@
 /tmp
 .vagrant
 .env
-database.yml
\ No newline at end of file
+database.yml
+vendor/bundle
+coverage