diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..625bdcd --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# TODO Comment out these rules if you are OK with secrets being uploaded to the repo +config/database.yml +config/initializers/secret_token.rb +config/secrets.yml + +## Environment normalisation: +/.bundle +/vendor/bundle + +log/*.log +tmp/**/* +public/system/* + +.irb_history +.idea +.DS_Store +*~ + +# these should all be checked in to normalise the environment: +# Gemfile.lock, .ruby-version, .ruby-gemset diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e82b85 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +#--warnings +--require spec_helper diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..c02c834 --- /dev/null +++ b/Gemfile @@ -0,0 +1,43 @@ +source 'https://rubygems.org' + +gem 'rails', '4.1.5' + +gem 'mysql2' + +gem 'slim-rails' +gem 'sass-rails', '~> 4.0.3' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'jquery-rails' +gem 'jbuilder', '~> 2.0' + +gem 'bootstrap-sass' +gem 'font-awesome-rails' + +# bundle exec rake doc:rails generates the API under doc/api. +#gem 'sdoc', '~> 0.4.0', group: :doc + +# Use unicorn as the app server +# gem 'unicorn' +# gem 'passenger' + +gem 'spring', group: :development + +group :development do + gem 'capistrano-ext' + gem 'capistrano-rails' + gem 'capistrano-rbenv' + gem 'capistrano-bundler' +end + +group :development, :test do + gem 'rspec-rails' + gem 'capybara' + gem 'webrat' + gem 'factory_girl_rails' +# gem 'selenium-webdriver' +end + +# Use debugger +# gem 'debugger', group: [:development, :test] + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..364cfc4 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,254 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) + mail (~> 2.5.4) + actionpack (4.1.5) + actionview (= 4.1.5) + activesupport (= 4.1.5) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + activerecord (4.1.5) + activemodel (= 4.1.5) + activesupport (= 4.1.5) + arel (~> 5.0.0) + activesupport (4.1.5) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + bootstrap-sass (3.2.0.1) + sass (~> 3.2) + builder (3.2.2) + capistrano (3.2.1) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.3) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-ext (1.2.1) + capistrano (>= 1.0.0) + capistrano-rails (1.1.1) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rbenv (2.0.2) + capistrano (~> 3.1) + sshkit (~> 1.3) + capybara (2.4.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + coffee-rails (4.0.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) + coffee-script-source + execjs + coffee-script-source (1.7.1) + colorize (0.7.3) + diff-lcs (1.2.5) + erubis (2.7.0) + execjs (2.2.1) + factory_girl (4.4.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.4.1) + factory_girl (~> 4.4.0) + railties (>= 3.0.0) + font-awesome-rails (4.1.0.0) + railties (>= 3.2, < 5.0) + hike (1.2.3) + i18n (0.6.11) + jbuilder (2.1.3) + activesupport (>= 3.0.0, < 5) + multi_json (~> 1.2) + jquery-rails (3.1.1) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + mini_portile (0.6.0) + minitest (5.4.0) + multi_json (1.10.1) + mysql2 (0.3.16) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) + nokogiri (1.6.3.1) + mini_portile (= 0.6.0) + polyglot (0.3.5) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.5) + actionmailer (= 4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) + activemodel (= 4.1.5) + activerecord (= 4.1.5) + activesupport (= 4.1.5) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.5) + sprockets-rails (~> 2.0) + railties (4.1.5) + actionpack (= 4.1.5) + activesupport (= 4.1.5) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) + rspec-core (3.0.4) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.4) + rspec-support (~> 3.0.0) + rspec-rails (3.0.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.4) + sass (3.2.19) + sass-rails (4.0.3) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) + slim (2.0.3) + temple (~> 0.6.6) + tilt (>= 1.3.3, < 2.1) + slim-rails (2.1.5) + actionpack (>= 3.0, < 4.2) + activesupport (>= 3.0, < 4.2) + railties (>= 3.0, < 4.2) + slim (~> 2.0) + spring (1.1.3) + sprockets (2.11.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.1.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + sshkit (1.5.1) + colorize + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + temple (0.6.8) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.5.3) + execjs (>= 0.3.0) + json (>= 1.8.0) + webrat (0.7.3) + nokogiri (>= 1.2.0) + rack (>= 1.0) + rack-test (>= 0.5.3) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + bootstrap-sass + capistrano-bundler + capistrano-ext + capistrano-rails + capistrano-rbenv + capybara + coffee-rails (~> 4.0.0) + factory_girl_rails + font-awesome-rails + jbuilder (~> 2.0) + jquery-rails + mysql2 + rails (= 4.1.5) + rspec-rails + sass-rails (~> 4.0.3) + slim-rails + spring + uglifier (>= 1.3.0) + webrat diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..921aebe --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require bootstrap +//= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..28a988c --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,17 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require bootstrap + *= require font-awesome + *= require_tree . + *= require_self + */ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..44e0f6b --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,12 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception + + after_action :cors_set_access_control_headers + + def cors_set_access_control_headers + headers['Access-Control-Allow-Origin'] = '*' + headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' + end +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb new file mode 100644 index 0000000..e76ea86 --- /dev/null +++ b/app/controllers/messages_controller.rb @@ -0,0 +1,37 @@ +class MessagesController < ApplicationController + before_action :set_message, only: [:show, :edit, :update] + + # GET /messages/1 + # GET /messages/1.json + def show + end + + # GET /messages/1/edit + def edit + end + + # PATCH/PUT /messages/1 + # PATCH/PUT /messages/1.json + def update + respond_to do |format| + if @message.update(message_params) + format.html { redirect_to @message, notice: 'Message was successfully updated.' } + format.json { render :show, status: :ok, location: @message } + else + format.html { render :edit } + format.json { render json: @message.errors, status: :unprocessable_entity } + end + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_message + @message = Message.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def message_params + params.require(:message).permit(:body) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..45d0854 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,42 @@ +module ApplicationHelper + def full_title(page_title = nil) + base_title = t('common.site_title') + + if page_title.blank? + base_title + else + "#{page_title} | #{base_title}" + end + end + + def nl2br(str) + str.gsub(/\r\n|\r|\n/, "
") + end + + def hbr(str) + str = html_escape(str) + str.gsub(/\r\n|\r|\n/, "
") + end + + def datetime_view(datetime) + return nil if datetime.blank? + datetime.strftime(t('time.formats.default')) + end + + def date_view(date) + return nil if date.blank? + date.strftime(t('date.formats.default')) + end + + # Public: Pick the correct arguments for form_for when shallow routes are used. + # + # parent - The Resource that has_* child + # child - The Resource that belongs_to parent. + def shallow_args(parent, child) + params[:action] == 'new' ? [parent, child] : child + end + + def shallow_deep_args(parent, child, grandchild) + params[:action] == 'new' ? [parent, child, grandchild] : grandchild + end +end diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb new file mode 100644 index 0000000..f1bca9f --- /dev/null +++ b/app/helpers/messages_helper.rb @@ -0,0 +1,2 @@ +module MessagesHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/message.rb b/app/models/message.rb new file mode 100644 index 0000000..590e3e3 --- /dev/null +++ b/app/models/message.rb @@ -0,0 +1,2 @@ +class Message < ActiveRecord::Base +end diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim new file mode 100644 index 0000000..24d3a9f --- /dev/null +++ b/app/views/layouts/application.html.slim @@ -0,0 +1,55 @@ +doctype html +html + head + meta charset="utf-8" + meta http-equiv="X-UA-Compatible" content="IE=Edge" + meta name="viewport" content="width=device-width" + title #{full_title(yield(:title))} + + /! Le HTML5 shim, for IE6-8 support of HTML elements + /[if lt IE 9] + = javascript_include_tag "html5shiv" + = stylesheet_link_tag "application", media: "all" + = javascript_include_tag "application" + = content_for :header + = csrf_meta_tags + + body + .navbar.navbar-inverse.navbar-static-top + .container + .navbar-header + button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + a.navbar-brand href="#{root_path}" + span.fa.fa-terminal + | #{t('common.site_title')} + .navbar-collapse.collapse + ul.nav.navbar-nav + li + a href="#" About + li + a href="#{edit_message_path(1)}" Edit + /!.navbar-collapse.collapse + + .container + .row + .col-sm-12.col-lg-12 + - unless notice.blank? + p.alert.alert-success #{notice} + - unless alert.blank? + p.alert.alert-danger #{alert} + + .page-header + h1 #{yield :title} + + = yield + + footer + hr + p.text-right + | #{t('common.site_title')} + span.fa.fa-cubes + | taketoketa.org diff --git a/app/views/messages/_form.html.slim b/app/views/messages/_form.html.slim new file mode 100644 index 0000000..892b138 --- /dev/null +++ b/app/views/messages/_form.html.slim @@ -0,0 +1,17 @@ += form_for @message, html: { class: "form-horizontal" } do |f| + - if @message.errors.any? + #error_explanation + h2 = "#{pluralize(@message.errors.count, "error")} prohibited this message from being saved:" + ul + - @message.errors.full_messages.each do |message| + li = message + + .form-group + .control-label.col-sm-2 + = f.label :body + .col-sm-6 + = f.text_area :body, class: "form-control" + + .form-group + .col-sm-10.col-sm-offset-2 + = f.submit class: "btn btn-primary" diff --git a/app/views/messages/edit.html.slim b/app/views/messages/edit.html.slim new file mode 100644 index 0000000..442833a --- /dev/null +++ b/app/views/messages/edit.html.slim @@ -0,0 +1,3 @@ +- provide :title, t('views.messages.edit.title') + +== render 'form' diff --git a/app/views/messages/show.html.slim b/app/views/messages/show.html.slim new file mode 100644 index 0000000..18c4356 --- /dev/null +++ b/app/views/messages/show.html.slim @@ -0,0 +1,4 @@ +- provide :title, t('views.messages.show.title') + +p.lead + = @message.body diff --git a/app/views/messages/show.json.jbuilder b/app/views/messages/show.json.jbuilder new file mode 100644 index 0000000..2ccaed8 --- /dev/null +++ b/app/views/messages/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @message, :id, :body, :created_at, :updated_at diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..00abda7 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,33 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +require "active_model/railtie" +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Say + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + config.time_zone = 'Tokyo' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s] + config.i18n.default_locale = :ja + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..5e5f0c1 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml.example b/config/database.yml.example new file mode 100644 index 0000000..7a1a16b --- /dev/null +++ b/config/database.yml.example @@ -0,0 +1,54 @@ +# MySQL. Versions 5.0+ are recommended. +# +# Install the MYSQL driver +# gem install mysql2 +# +# Ensure the MySQL gem is defined in your Gemfile +# gem 'mysql2' +# +# And be sure to use new-style password hashing: +# http://dev.mysql.com/doc/refman/5.0/en/old-client.html +# +default: &default + adapter: mysql2 + encoding: utf8 + pool: 5 + username: root + password: password + socket: /tmp/mysql.sock + +development: + <<: *default + database: say_development + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: say_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: say_production + username: say + password: <%= ENV['SAY_DATABASE_PASSWORD'] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..66d0b05 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,44 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { :host => 'localhost:3000' } + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # debug Strong Parameters + config.action_controller.action_on_unpermitted_parameters = :raise + + # Indent html for pretty debugging + Slim::Engine.set_default_options :pretty => true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..4722e45 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,85 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` has moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Indent html for pretty debugging + Slim::Engine.set_default_options :pretty => true +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..e6ef16c --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_say_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/application.en.yml b/config/locales/application.en.yml new file mode 100644 index 0000000..560463c --- /dev/null +++ b/config/locales/application.en.yml @@ -0,0 +1,30 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + common: + site_title: "Say!" + helpers: + actions: "Actions" + links: + back: "Back" + cancel: "Cancel" + confirm: "Are you sure?" + destroy: "Delete" + new: "New" + edit: "Edit" + update: "Update" + login: "Login" + logout: "Logout" + views: + messages: + show: + title: 'Message' + edit: + title: 'Editing message' + activerecord: + models: + message: message + attributes: + message: + body: message diff --git a/config/locales/application.ja.yml b/config/locales/application.ja.yml new file mode 100644 index 0000000..e629a98 --- /dev/null +++ b/config/locales/application.ja.yml @@ -0,0 +1,30 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +ja: + common: + site_title: "Say!" + helpers: + actions: "Actions" + links: + back: "戻る" + cancel: "キャンセル" + confirm: "削除してもよろしいですか?" + destroy: "削除" + new: "新規登録" + edit: "編集" + update: "更新" + login: "ログイン" + logout: "ログアウト" + views: + messages: + show: + title: 'メッセージ' + edit: + title: 'メッセージ編集' + activerecord: + models: + message: メッセージ + attributes: + message: + body: メッセージ diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..2259763 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,214 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + date: + abbr_day_names: + - Sun + - Mon + - Tue + - Wed + - Thu + - Fri + - Sat + abbr_month_names: + - + - Jan + - Feb + - Mar + - Apr + - May + - Jun + - Jul + - Aug + - Sep + - Oct + - Nov + - Dec + day_names: + - Sunday + - Monday + - Tuesday + - Wednesday + - Thursday + - Friday + - Saturday + formats: + default: ! '%Y-%m-%d' + long: ! '%B %d, %Y' + short: ! '%b %d' + month_names: + - + - January + - February + - March + - April + - May + - June + - July + - August + - September + - October + - November + - December + order: + - :year + - :month + - :day + datetime: + distance_in_words: + about_x_hours: + one: about 1 hour + other: about %{count} hours + about_x_months: + one: about 1 month + other: about %{count} months + about_x_years: + one: about 1 year + other: about %{count} years + almost_x_years: + one: almost 1 year + other: almost %{count} years + half_a_minute: half a minute + less_than_x_minutes: + one: less than a minute + other: less than %{count} minutes + less_than_x_seconds: + one: less than 1 second + other: less than %{count} seconds + over_x_years: + one: over 1 year + other: over %{count} years + x_days: + one: 1 day + other: ! '%{count} days' + x_minutes: + one: 1 minute + other: ! '%{count} minutes' + x_months: + one: 1 month + other: ! '%{count} months' + x_seconds: + one: 1 second + other: ! '%{count} seconds' + prompts: + day: Day + hour: Hour + minute: Minute + month: Month + second: Seconds + year: Year + errors: &errors + format: ! '%{attribute} %{message}' + messages: + accepted: must be accepted + blank: can't be blank + present: must be blank + confirmation: ! "doesn't match %{attribute}" + empty: can't be empty + equal_to: must be equal to %{count} + even: must be even + exclusion: is reserved + greater_than: must be greater than %{count} + greater_than_or_equal_to: must be greater than or equal to %{count} + inclusion: is not included in the list + invalid: is invalid + less_than: must be less than %{count} + less_than_or_equal_to: must be less than or equal to %{count} + not_a_number: is not a number + not_an_integer: must be an integer + odd: must be odd + record_invalid: ! 'Validation failed: %{errors}' + restrict_dependent_destroy: + one: "Cannot delete record because a dependent %{record} exists" + many: "Cannot delete record because dependent %{record} exist" + taken: has already been taken + too_long: + one: is too long (maximum is 1 character) + other: is too long (maximum is %{count} characters) + too_short: + one: is too short (minimum is 1 character) + other: is too short (minimum is %{count} characters) + wrong_length: + one: is the wrong length (should be 1 character) + other: is the wrong length (should be %{count} characters) + other_than: "must be other than %{count}" + template: + body: ! 'There were problems with the following fields:' + header: + one: 1 error prohibited this %{model} from being saved + other: ! '%{count} errors prohibited this %{model} from being saved' + helpers: + select: + prompt: Please select + submit: + create: Create %{model} + submit: Save %{model} + update: Update %{model} + number: + currency: + format: + delimiter: ! ',' + format: ! '%u%n' + precision: 2 + separator: . + significant: false + strip_insignificant_zeros: false + unit: $ + format: + delimiter: ! ',' + precision: 3 + separator: . + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: ! '%n %u' + units: + billion: Billion + million: Million + quadrillion: Quadrillion + thousand: Thousand + trillion: Trillion + unit: '' + format: + delimiter: '' + precision: 3 + significant: true + strip_insignificant_zeros: true + storage_units: + format: ! '%n %u' + units: + byte: + one: Byte + other: Bytes + gb: GB + kb: KB + mb: MB + tb: TB + percentage: + format: + delimiter: '' + format: "%n%" + precision: + format: + delimiter: '' + support: + array: + last_word_connector: ! ', and ' + two_words_connector: ! ' and ' + words_connector: ! ', ' + time: + am: am + formats: + default: ! '%a, %d %b %Y %H:%M:%S %z' + long: ! '%B %d, %Y %H:%M' + short: ! '%d %b %H:%M' + pm: pm + # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository + activemodel: + errors: + <<: *errors + activerecord: + errors: + <<: *errors diff --git a/config/locales/ja.yml b/config/locales/ja.yml new file mode 100644 index 0000000..6eefd8f --- /dev/null +++ b/config/locales/ja.yml @@ -0,0 +1,204 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +ja: + date: + abbr_day_names: + - 日 + - 月 + - 火 + - 水 + - 木 + - 金 + - 土 + abbr_month_names: + - + - 1月 + - 2月 + - 3月 + - 4月 + - 5月 + - 6月 + - 7月 + - 8月 + - 9月 + - 10月 + - 11月 + - 12月 + day_names: + - 日曜日 + - 月曜日 + - 火曜日 + - 水曜日 + - 木曜日 + - 金曜日 + - 土曜日 + formats: + default: ! '%Y/%m/%d' + long: ! '%Y年%m月%d日(%a)' + short: ! '%m/%d' + month_names: + - + - 1月 + - 2月 + - 3月 + - 4月 + - 5月 + - 6月 + - 7月 + - 8月 + - 9月 + - 10月 + - 11月 + - 12月 + order: + - :year + - :month + - :day + datetime: + distance_in_words: + about_x_hours: + one: 約1時間 + other: 約%{count}時間 + about_x_months: + one: 約1ヶ月 + other: 約%{count}ヶ月 + about_x_years: + one: 約1年 + other: 約%{count}年 + almost_x_years: + one: 1年弱 + other: ! '%{count}年弱' + half_a_minute: 30秒前後 + less_than_x_minutes: + one: 1分以内 + other: ! '%{count}分未満' + less_than_x_seconds: + one: 1秒以内 + other: ! '%{count}秒未満' + over_x_years: + one: 1年以上 + other: ! '%{count}年以上' + x_days: + one: 1日 + other: ! '%{count}日' + x_minutes: + one: 1分 + other: ! '%{count}分' + x_months: + one: 1ヶ月 + other: ! '%{count}ヶ月' + x_seconds: + one: 1秒 + other: ! '%{count}秒' + prompts: + day: 日 + hour: 時 + minute: 分 + month: 月 + second: 秒 + year: 年 + errors: &errors + format: ! '%{attribute}%{message}' + messages: + accepted: を受諾してください。 + blank: を入力してください。 + present: は入力しないでください。 + confirmation: と%{attribute}の入力が一致しません。 + empty: を入力してください。 + equal_to: は%{count}にしてください。 + even: は偶数にしてください。 + exclusion: は予約されています。 + greater_than: は%{count}より大きい値にしてください。 + greater_than_or_equal_to: は%{count}以上の値にしてください。 + inclusion: は一覧にありません。 + invalid: は不正な値です。 + less_than: は%{count}より小さい値にしてください。 + less_than_or_equal_to: は%{count}以下の値にしてください。 + not_a_number: は数値で入力してください。 + not_an_integer: は整数で入力してください。 + odd: は奇数にしてください。 + record_invalid: バリデーションに失敗しました。 %{errors} + restrict_dependent_destroy: ! '%{record}が存在しているので削除できません。' + taken: はすでに存在します。 + too_long: は%{count}文字以内で入力してください。 + too_short: は%{count}文字以上で入力してください。 + wrong_length: は%{count}文字で入力してください。 + other_than: "は%{count}以外の値にしてください。" + template: + body: 次の項目を確認してください。 + header: + one: ! '%{model}にエラーが発生しました。' + other: ! '%{model}に%{count}個のエラーが発生しました。' + helpers: + select: + prompt: 選択してください。 + submit: + create: 登録 + submit: 保存 + update: 更新 + number: + currency: + format: + delimiter: ! ',' + format: ! '%n%u' + precision: 0 + separator: . + significant: false + strip_insignificant_zeros: false + unit: 円 + format: + delimiter: ! ',' + precision: 3 + separator: . + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: ! '%n %u' + units: + billion: 十億 + million: 百万 + quadrillion: 千兆 + thousand: 千 + trillion: 兆 + unit: '' + format: + delimiter: '' + precision: 3 + significant: true + strip_insignificant_zeros: true + storage_units: + format: ! '%n%u' + units: + byte: バイト + gb: ギガバイト + kb: キロバイト + mb: メガバイト + tb: テラバイト + percentage: + format: + delimiter: '' + format: "%n%" + precision: + format: + delimiter: '' + support: + array: + last_word_connector: と + two_words_connector: と + words_connector: と + time: + am: 午前 + formats: + default: ! '%Y/%m/%d %H:%M:%S' + long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z' + short: ! '%y/%m/%d %H:%M' + pm: 午後 + # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository + activemodel: + errors: + <<: *errors + activerecord: + errors: + <<: *errors diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..cf43497 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,5 @@ +Rails.application.routes.draw do + root to: 'messages#show', id: '1' + + resources :messages, only: [ :show, :edit, :update ] +end diff --git a/db/migrate/20140822170751_create_messages.rb b/db/migrate/20140822170751_create_messages.rb new file mode 100644 index 0000000..ecef805 --- /dev/null +++ b/db/migrate/20140822170751_create_messages.rb @@ -0,0 +1,9 @@ +class CreateMessages < ActiveRecord::Migration + def change + create_table :messages do |t| + t.text :body + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..c723888 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20140822170751) do + + create_table "messages", force: true do |t| + t.text "body" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..0a1337c --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,9 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) + +Message.create(body: 'Hello, world!') diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb new file mode 100644 index 0000000..f127cf5 --- /dev/null +++ b/spec/controllers/messages_controller_spec.rb @@ -0,0 +1,96 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +RSpec.describe MessagesController, :type => :controller do + + # This should return the minimal set of attributes required to create a valid + # Message. As you add validations to Message, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + { body: 'Hello, world!' } + } + + let(:invalid_attributes) { + { body: nil } + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # MessagesController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET show" do + it "assigns the requested message as @message" do + message = Message.create! valid_attributes + get :show, {:id => message.to_param}, valid_session + expect(assigns(:message)).to eq(message) + end + end + + describe "GET edit" do + it "assigns the requested message as @message" do + message = Message.create! valid_attributes + get :edit, {:id => message.to_param}, valid_session + expect(assigns(:message)).to eq(message) + end + end + + describe "PUT update" do + describe "with valid params" do + let(:new_attributes) { + { body: 'test' } + } + + it "updates the requested message" do + message = Message.create! valid_attributes + put :update, {:id => message.to_param, :message => new_attributes}, valid_session + message.reload + expect(message.body).to eq new_attributes[:body] + end + + it "assigns the requested message as @message" do + message = Message.create! valid_attributes + put :update, {:id => message.to_param, :message => valid_attributes}, valid_session + expect(assigns(:message)).to eq(message) + end + + it "redirects to the message" do + message = Message.create! valid_attributes + put :update, {:id => message.to_param, :message => valid_attributes}, valid_session + expect(response).to redirect_to(message) + end + end + +# describe "with invalid params" do +# it "assigns the message as @message" do +# message = Message.create! valid_attributes +# put :update, {:id => message.to_param, :message => invalid_attributes}, valid_session +# expect(assigns(:message)).to eq(message) +# end +# +# it "re-renders the 'edit' template" do +# message = Message.create! valid_attributes +# put :update, {:id => message.to_param, :message => invalid_attributes}, valid_session +# expect(response).to render_template("edit") +# end +# end + end + +end diff --git a/spec/factories/messages.rb b/spec/factories/messages.rb new file mode 100644 index 0000000..5d894d7 --- /dev/null +++ b/spec/factories/messages.rb @@ -0,0 +1,7 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :message do + body "Hello, world!" + end +end diff --git a/spec/helpers/messages_helper_spec.rb b/spec/helpers/messages_helper_spec.rb new file mode 100644 index 0000000..42cca3a --- /dev/null +++ b/spec/helpers/messages_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the MessagesHelper. For example: +# +# describe MessagesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe MessagesHelper, :type => :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb new file mode 100644 index 0000000..37e8e9f --- /dev/null +++ b/spec/models/message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Message, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..4d1d439 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,43 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require 'spec_helper' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } + +# Checks for pending migrations before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! +end diff --git a/spec/requests/messages_spec.rb b/spec/requests/messages_spec.rb new file mode 100644 index 0000000..bc6df9d --- /dev/null +++ b/spec/requests/messages_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +RSpec.describe "Messages", :type => :request do + before(:each) do + @message = FactoryGirl.create(:message) + end + + describe "GET /messages/1" do + it "works!" do + get message_path(@message) + expect(response.status).to be(200) + end + end + + describe "GET /messages/edit/1" do + it "works!" do + get edit_message_path(@message) + expect(response.status).to be(200) + end + end +end diff --git a/spec/routing/messages_routing_spec.rb b/spec/routing/messages_routing_spec.rb new file mode 100644 index 0000000..e66a0db --- /dev/null +++ b/spec/routing/messages_routing_spec.rb @@ -0,0 +1,40 @@ +require "rails_helper" + +RSpec.describe MessagesController, :type => :routing do + describe "routing" do + + it "routes to root" do + expect(:get => "/").to route_to("messages#show", id: "1") + end + + it "routes to #show" do + expect(:get => "/messages/1").to route_to("messages#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/messages/1/edit").to route_to("messages#edit", :id => "1") + end + + it "routes to #update" do + expect(:put => "/messages/1").to route_to("messages#update", :id => "1") + end + + context "not exist" do + it "routes to #create" do + expect(:post => "/messages").not_to route_to("messages#create") + end + + it "routes to #index" do + expect(:get => "/messages").not_to route_to("messages#index") + end + + it "routes to #new" do + expect(:get => "/messages/new").not_to route_to("messages#new") + end + + it "routes to #destroy" do + expect(:delete => "/messages/1").not_to route_to("messages#destroy", :id => "1") + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..4692320 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,76 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause this +# file to always be loaded, without a need to explicitly require it in any files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, make a +# separate helper file that requires this one and then use it only in the specs +# that actually need it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. +# config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed + + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + expectations.syntax = :expect + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + mocks.syntax = :expect + + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended. + mocks.verify_partial_doubles = true + end +end diff --git a/spec/views/messages/edit.html.slim_spec.rb b/spec/views/messages/edit.html.slim_spec.rb new file mode 100644 index 0000000..8808bf8 --- /dev/null +++ b/spec/views/messages/edit.html.slim_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "messages/edit", :type => :view do + before(:each) do + @message = assign(:message, Message.create!( + :body => "MyText" + )) + end + + it "renders the edit message form" do + render + + assert_select "form[action=?][method=?]", message_path(@message), "post" do + + assert_select "textarea#message_body[name=?]", "message[body]" + end + end +end diff --git a/spec/views/messages/show.html.slim_spec.rb b/spec/views/messages/show.html.slim_spec.rb new file mode 100644 index 0000000..ee82947 --- /dev/null +++ b/spec/views/messages/show.html.slim_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe "messages/show", :type => :view do + before(:each) do + @message = assign(:message, Message.create!( + :body => "MyText" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/MyText/) + end +end diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29