From e9f89fe6595da1ecfe7b6756cddaf897dfc480ab Mon Sep 17 00:00:00 2001 From: michal Date: Fri, 12 Sep 2014 16:46:59 +0200 Subject: [PATCH] Done --- .gitignore | 0 Gemfile | 0 Gemfile.lock | 0 README.rdoc | 0 Rakefile | 0 app/assets/images/.keep | 0 app/assets/javascripts/application.js | 0 app/assets/javascripts/microposts.js.coffee | 3 + app/assets/javascripts/users.js.coffee | 3 + app/assets/stylesheets/application.css | 0 app/assets/stylesheets/microposts.css.scss | 3 + app/assets/stylesheets/scaffolds.css.scss | 69 +++++++++++++++++ app/assets/stylesheets/users.css.scss | 3 + app/controllers/application_controller.rb | 0 app/controllers/concerns/.keep | 0 app/controllers/microposts_controller.rb | 74 +++++++++++++++++++ app/controllers/users_controller.rb | 74 +++++++++++++++++++ app/helpers/application_helper.rb | 0 app/helpers/microposts_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/mailers/.keep | 0 app/models/.keep | 0 app/models/concerns/.keep | 0 app/models/micropost.rb | 6 ++ app/models/user.rb | 4 + app/views/layouts/application.html.erb | 0 app/views/microposts/_form.html.erb | 25 +++++++ app/views/microposts/edit.html.erb | 6 ++ app/views/microposts/index.html.erb | 27 +++++++ app/views/microposts/index.json.jbuilder | 4 + app/views/microposts/new.html.erb | 5 ++ app/views/microposts/show.html.erb | 14 ++++ app/views/microposts/show.json.jbuilder | 1 + app/views/users/_form.html.erb | 25 +++++++ app/views/users/edit.html.erb | 6 ++ app/views/users/index.html.erb | 27 +++++++ app/views/users/index.json.jbuilder | 4 + app/views/users/new.html.erb | 5 ++ app/views/users/show.html.erb | 14 ++++ app/views/users/show.json.jbuilder | 1 + config.ru | 0 config/application.rb | 0 config/boot.rb | 0 config/database.yml | 0 config/environment.rb | 0 config/environments/development.rb | 0 config/environments/production.rb | 0 config/environments/test.rb | 0 config/initializers/assets.rb | 0 config/initializers/backtrace_silencers.rb | 0 config/initializers/cookies_serializer.rb | 0 .../initializers/filter_parameter_logging.rb | 0 config/initializers/inflections.rb | 0 config/initializers/mime_types.rb | 0 config/initializers/session_store.rb | 0 config/initializers/wrap_parameters.rb | 0 config/locales/en.yml | 0 config/routes.rb | 4 + config/secrets.yml | 0 db/migrate/20140912123320_create_users.rb | 10 +++ .../20140912142556_create_microposts.rb | 10 +++ db/schema.rb | 33 +++++++++ db/seeds.rb | 0 lib/assets/.keep | 0 lib/tasks/.keep | 0 log/.keep | 0 public/404.html | 0 public/422.html | 0 public/500.html | 0 public/favicon.ico | 0 public/robots.txt | 0 test/controllers/.keep | 0 .../controllers/microposts_controller_test.rb | 49 ++++++++++++ test/controllers/users_controller_test.rb | 49 ++++++++++++ test/fixtures/.keep | 0 test/fixtures/microposts.yml | 9 +++ test/fixtures/users.yml | 9 +++ test/helpers/.keep | 0 test/helpers/microposts_helper_test.rb | 4 + test/helpers/users_helper_test.rb | 4 + test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/models/micropost_test.rb | 7 ++ test/models/user_test.rb | 7 ++ test/test_helper.rb | 0 vendor/assets/javascripts/.keep | 0 vendor/assets/stylesheets/.keep | 0 88 files changed, 602 insertions(+) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 Gemfile mode change 100644 => 100755 Gemfile.lock mode change 100644 => 100755 README.rdoc mode change 100644 => 100755 Rakefile mode change 100644 => 100755 app/assets/images/.keep mode change 100644 => 100755 app/assets/javascripts/application.js create mode 100755 app/assets/javascripts/microposts.js.coffee create mode 100755 app/assets/javascripts/users.js.coffee mode change 100644 => 100755 app/assets/stylesheets/application.css create mode 100755 app/assets/stylesheets/microposts.css.scss create mode 100755 app/assets/stylesheets/scaffolds.css.scss create mode 100755 app/assets/stylesheets/users.css.scss mode change 100644 => 100755 app/controllers/application_controller.rb mode change 100644 => 100755 app/controllers/concerns/.keep create mode 100755 app/controllers/microposts_controller.rb create mode 100755 app/controllers/users_controller.rb mode change 100644 => 100755 app/helpers/application_helper.rb create mode 100755 app/helpers/microposts_helper.rb create mode 100755 app/helpers/users_helper.rb mode change 100644 => 100755 app/mailers/.keep mode change 100644 => 100755 app/models/.keep mode change 100644 => 100755 app/models/concerns/.keep create mode 100755 app/models/micropost.rb create mode 100755 app/models/user.rb mode change 100644 => 100755 app/views/layouts/application.html.erb create mode 100755 app/views/microposts/_form.html.erb create mode 100755 app/views/microposts/edit.html.erb create mode 100755 app/views/microposts/index.html.erb create mode 100755 app/views/microposts/index.json.jbuilder create mode 100755 app/views/microposts/new.html.erb create mode 100755 app/views/microposts/show.html.erb create mode 100755 app/views/microposts/show.json.jbuilder create mode 100755 app/views/users/_form.html.erb create mode 100755 app/views/users/edit.html.erb create mode 100755 app/views/users/index.html.erb create mode 100755 app/views/users/index.json.jbuilder create mode 100755 app/views/users/new.html.erb create mode 100755 app/views/users/show.html.erb create mode 100755 app/views/users/show.json.jbuilder mode change 100644 => 100755 config.ru mode change 100644 => 100755 config/application.rb mode change 100644 => 100755 config/boot.rb mode change 100644 => 100755 config/database.yml mode change 100644 => 100755 config/environment.rb mode change 100644 => 100755 config/environments/development.rb mode change 100644 => 100755 config/environments/production.rb mode change 100644 => 100755 config/environments/test.rb mode change 100644 => 100755 config/initializers/assets.rb mode change 100644 => 100755 config/initializers/backtrace_silencers.rb mode change 100644 => 100755 config/initializers/cookies_serializer.rb mode change 100644 => 100755 config/initializers/filter_parameter_logging.rb mode change 100644 => 100755 config/initializers/inflections.rb mode change 100644 => 100755 config/initializers/mime_types.rb mode change 100644 => 100755 config/initializers/session_store.rb mode change 100644 => 100755 config/initializers/wrap_parameters.rb mode change 100644 => 100755 config/locales/en.yml mode change 100644 => 100755 config/routes.rb mode change 100644 => 100755 config/secrets.yml create mode 100755 db/migrate/20140912123320_create_users.rb create mode 100755 db/migrate/20140912142556_create_microposts.rb create mode 100755 db/schema.rb mode change 100644 => 100755 db/seeds.rb mode change 100644 => 100755 lib/assets/.keep mode change 100644 => 100755 lib/tasks/.keep mode change 100644 => 100755 log/.keep mode change 100644 => 100755 public/404.html mode change 100644 => 100755 public/422.html mode change 100644 => 100755 public/500.html mode change 100644 => 100755 public/favicon.ico mode change 100644 => 100755 public/robots.txt mode change 100644 => 100755 test/controllers/.keep create mode 100755 test/controllers/microposts_controller_test.rb create mode 100755 test/controllers/users_controller_test.rb mode change 100644 => 100755 test/fixtures/.keep create mode 100755 test/fixtures/microposts.yml create mode 100755 test/fixtures/users.yml mode change 100644 => 100755 test/helpers/.keep create mode 100755 test/helpers/microposts_helper_test.rb create mode 100755 test/helpers/users_helper_test.rb mode change 100644 => 100755 test/integration/.keep mode change 100644 => 100755 test/mailers/.keep mode change 100644 => 100755 test/models/.keep create mode 100755 test/models/micropost_test.rb create mode 100755 test/models/user_test.rb mode change 100644 => 100755 test/test_helper.rb mode change 100644 => 100755 vendor/assets/javascripts/.keep mode change 100644 => 100755 vendor/assets/stylesheets/.keep diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Gemfile b/Gemfile old mode 100644 new mode 100755 diff --git a/Gemfile.lock b/Gemfile.lock old mode 100644 new mode 100755 diff --git a/README.rdoc b/README.rdoc old mode 100644 new mode 100755 diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 diff --git a/app/assets/images/.keep b/app/assets/images/.keep old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/microposts.js.coffee b/app/assets/javascripts/microposts.js.coffee new file mode 100755 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/microposts.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee new file mode 100755 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/users.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/microposts.css.scss b/app/assets/stylesheets/microposts.css.scss new file mode 100755 index 0000000..c14d62c --- /dev/null +++ b/app/assets/stylesheets/microposts.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Microposts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100755 index 0000000..6ec6a8f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss new file mode 100755 index 0000000..31a2eac --- /dev/null +++ b/app/assets/stylesheets/users.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb old mode 100644 new mode 100755 diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep old mode 100644 new mode 100755 diff --git a/app/controllers/microposts_controller.rb b/app/controllers/microposts_controller.rb new file mode 100755 index 0000000..c36ac0b --- /dev/null +++ b/app/controllers/microposts_controller.rb @@ -0,0 +1,74 @@ +class MicropostsController < ApplicationController + before_action :set_micropost, only: [:show, :edit, :update, :destroy] + + # GET /microposts + # GET /microposts.json + def index + @microposts = Micropost.all + end + + # GET /microposts/1 + # GET /microposts/1.json + def show + end + + # GET /microposts/new + def new + @micropost = Micropost.new + end + + # GET /microposts/1/edit + def edit + end + + # POST /microposts + # POST /microposts.json + def create + @micropost = Micropost.new(micropost_params) + + respond_to do |format| + if @micropost.save + format.html { redirect_to @micropost, notice: 'Micropost was successfully created.' } + format.json { render :show, status: :created, location: @micropost } + else + format.html { render :new } + format.json { render json: @micropost.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /microposts/1 + # PATCH/PUT /microposts/1.json + def update + respond_to do |format| + if @micropost.update(micropost_params) + format.html { redirect_to @micropost, notice: 'Micropost was successfully updated.' } + format.json { render :show, status: :ok, location: @micropost } + else + format.html { render :edit } + format.json { render json: @micropost.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /microposts/1 + # DELETE /microposts/1.json + def destroy + @micropost.destroy + respond_to do |format| + format.html { redirect_to microposts_url, notice: 'Micropost was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_micropost + @micropost = Micropost.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def micropost_params + params.require(:micropost).permit(:content, :user_id) + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100755 index 0000000..46b6a95 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,74 @@ +class UsersController < ApplicationController + before_action :set_user, only: [:show, :edit, :update, :destroy] + + # GET /users + # GET /users.json + def index + @users = User.all + end + + # GET /users/1 + # GET /users/1.json + def show + end + + # GET /users/new + def new + @user = User.new + end + + # GET /users/1/edit + def edit + end + + # POST /users + # POST /users.json + def create + @user = User.new(user_params) + + respond_to do |format| + if @user.save + format.html { redirect_to @user, notice: 'User was successfully created.' } + format.json { render :show, status: :created, location: @user } + else + format.html { render :new } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /users/1 + # PATCH/PUT /users/1.json + def update + respond_to do |format| + if @user.update(user_params) + format.html { redirect_to @user, notice: 'User was successfully updated.' } + format.json { render :show, status: :ok, location: @user } + else + format.html { render :edit } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /users/1 + # DELETE /users/1.json + def destroy + @user.destroy + respond_to do |format| + format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_user + @user = User.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def user_params + params.require(:user).permit(:name, :email) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/microposts_helper.rb b/app/helpers/microposts_helper.rb new file mode 100755 index 0000000..f08aad2 --- /dev/null +++ b/app/helpers/microposts_helper.rb @@ -0,0 +1,2 @@ +module MicropostsHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100755 index 0000000..2310a24 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep old mode 100644 new mode 100755 diff --git a/app/models/.keep b/app/models/.keep old mode 100644 new mode 100755 diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep old mode 100644 new mode 100755 diff --git a/app/models/micropost.rb b/app/models/micropost.rb new file mode 100755 index 0000000..7bc48ac --- /dev/null +++ b/app/models/micropost.rb @@ -0,0 +1,6 @@ +class Micropost < ActiveRecord::Base + + belongs_to :user + + validates :content, length: { maximum: 140 } +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100755 index 0000000..b6154d1 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,4 @@ +class User < ActiveRecord::Base + + has_many :microposts +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb old mode 100644 new mode 100755 diff --git a/app/views/microposts/_form.html.erb b/app/views/microposts/_form.html.erb new file mode 100755 index 0000000..586a952 --- /dev/null +++ b/app/views/microposts/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@micropost) do |f| %> + <% if @micropost.errors.any? %> +
+

<%= pluralize(@micropost.errors.count, "error") %> prohibited this micropost from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :content %>
+ <%= f.text_field :content %> +
+
+ <%= f.label :user_id %>
+ <%= f.number_field :user_id %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/microposts/edit.html.erb b/app/views/microposts/edit.html.erb new file mode 100755 index 0000000..30f1480 --- /dev/null +++ b/app/views/microposts/edit.html.erb @@ -0,0 +1,6 @@ +

Editing micropost

+ +<%= render 'form' %> + +<%= link_to 'Show', @micropost %> | +<%= link_to 'Back', microposts_path %> diff --git a/app/views/microposts/index.html.erb b/app/views/microposts/index.html.erb new file mode 100755 index 0000000..1c924c3 --- /dev/null +++ b/app/views/microposts/index.html.erb @@ -0,0 +1,27 @@ +

Listing microposts

+ + + + + + + + + + + + <% @microposts.each do |micropost| %> + + + + + + + + <% end %> + +
ContentUser
<%= micropost.content %><%= micropost.user_id %><%= link_to 'Show', micropost %><%= link_to 'Edit', edit_micropost_path(micropost) %><%= link_to 'Destroy', micropost, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Micropost', new_micropost_path %> diff --git a/app/views/microposts/index.json.jbuilder b/app/views/microposts/index.json.jbuilder new file mode 100755 index 0000000..e3c4c35 --- /dev/null +++ b/app/views/microposts/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@microposts) do |micropost| + json.extract! micropost, :id, :content, :user_id + json.url micropost_url(micropost, format: :json) +end diff --git a/app/views/microposts/new.html.erb b/app/views/microposts/new.html.erb new file mode 100755 index 0000000..b0ef41f --- /dev/null +++ b/app/views/microposts/new.html.erb @@ -0,0 +1,5 @@ +

New micropost

+ +<%= render 'form' %> + +<%= link_to 'Back', microposts_path %> diff --git a/app/views/microposts/show.html.erb b/app/views/microposts/show.html.erb new file mode 100755 index 0000000..0e55f60 --- /dev/null +++ b/app/views/microposts/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

+ Content: + <%= @micropost.content %> +

+ +

+ User: + <%= @micropost.user_id %> +

+ +<%= link_to 'Edit', edit_micropost_path(@micropost) %> | +<%= link_to 'Back', microposts_path %> diff --git a/app/views/microposts/show.json.jbuilder b/app/views/microposts/show.json.jbuilder new file mode 100755 index 0000000..26c3e45 --- /dev/null +++ b/app/views/microposts/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @micropost, :id, :content, :user_id, :created_at, :updated_at diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb new file mode 100755 index 0000000..2f360ea --- /dev/null +++ b/app/views/users/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@user) do |f| %> + <% if @user.errors.any? %> +
+

<%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :email %>
+ <%= f.text_field :email %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb new file mode 100755 index 0000000..99bd4cc --- /dev/null +++ b/app/views/users/edit.html.erb @@ -0,0 +1,6 @@ +

Editing user

+ +<%= render 'form' %> + +<%= link_to 'Show', @user %> | +<%= link_to 'Back', users_path %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100755 index 0000000..6041d5e --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,27 @@ +

Listing users

+ + + + + + + + + + + + <% @users.each do |user| %> + + + + + + + + <% end %> + +
NameEmail
<%= user.name %><%= user.email %><%= link_to 'Show', user %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New User', new_user_path %> diff --git a/app/views/users/index.json.jbuilder b/app/views/users/index.json.jbuilder new file mode 100755 index 0000000..2972532 --- /dev/null +++ b/app/views/users/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@users) do |user| + json.extract! user, :id, :name, :email + json.url user_url(user, format: :json) +end diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100755 index 0000000..efc0404 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,5 @@ +

New user

+ +<%= render 'form' %> + +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100755 index 0000000..3816c64 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

+ Name: + <%= @user.name %> +

+ +

+ Email: + <%= @user.email %> +

+ +<%= link_to 'Edit', edit_user_path(@user) %> | +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder new file mode 100755 index 0000000..53f1bb9 --- /dev/null +++ b/app/views/users/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @user, :id, :name, :email, :created_at, :updated_at diff --git a/config.ru b/config.ru old mode 100644 new mode 100755 diff --git a/config/application.rb b/config/application.rb old mode 100644 new mode 100755 diff --git a/config/boot.rb b/config/boot.rb old mode 100644 new mode 100755 diff --git a/config/database.yml b/config/database.yml old mode 100644 new mode 100755 diff --git a/config/environment.rb b/config/environment.rb old mode 100644 new mode 100755 diff --git a/config/environments/development.rb b/config/environments/development.rb old mode 100644 new mode 100755 diff --git a/config/environments/production.rb b/config/environments/production.rb old mode 100644 new mode 100755 diff --git a/config/environments/test.rb b/config/environments/test.rb old mode 100644 new mode 100755 diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb old mode 100644 new mode 100755 diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb old mode 100644 new mode 100755 diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb old mode 100644 new mode 100755 diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb old mode 100644 new mode 100755 diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb old mode 100644 new mode 100755 diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb old mode 100644 new mode 100755 diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb old mode 100644 new mode 100755 diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb old mode 100644 new mode 100755 diff --git a/config/locales/en.yml b/config/locales/en.yml old mode 100644 new mode 100755 diff --git a/config/routes.rb b/config/routes.rb old mode 100644 new mode 100755 index 3f66539..74dc48f --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,8 @@ Rails.application.routes.draw do + resources :microposts + + resources :users + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/config/secrets.yml b/config/secrets.yml old mode 100644 new mode 100755 diff --git a/db/migrate/20140912123320_create_users.rb b/db/migrate/20140912123320_create_users.rb new file mode 100755 index 0000000..7e0dcd9 --- /dev/null +++ b/db/migrate/20140912123320_create_users.rb @@ -0,0 +1,10 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + + t.timestamps + end + end +end diff --git a/db/migrate/20140912142556_create_microposts.rb b/db/migrate/20140912142556_create_microposts.rb new file mode 100755 index 0000000..1ea9615 --- /dev/null +++ b/db/migrate/20140912142556_create_microposts.rb @@ -0,0 +1,10 @@ +class CreateMicroposts < ActiveRecord::Migration + def change + create_table :microposts do |t| + t.string :content + t.integer :user_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100755 index 0000000..6f1ed83 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,33 @@ +# 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: 20140912142556) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "microposts", force: true do |t| + t.string "content" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", force: true do |t| + t.string "name" + t.string "email" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb old mode 100644 new mode 100755 diff --git a/lib/assets/.keep b/lib/assets/.keep old mode 100644 new mode 100755 diff --git a/lib/tasks/.keep b/lib/tasks/.keep old mode 100644 new mode 100755 diff --git a/log/.keep b/log/.keep old mode 100644 new mode 100755 diff --git a/public/404.html b/public/404.html old mode 100644 new mode 100755 diff --git a/public/422.html b/public/422.html old mode 100644 new mode 100755 diff --git a/public/500.html b/public/500.html old mode 100644 new mode 100755 diff --git a/public/favicon.ico b/public/favicon.ico old mode 100644 new mode 100755 diff --git a/public/robots.txt b/public/robots.txt old mode 100644 new mode 100755 diff --git a/test/controllers/.keep b/test/controllers/.keep old mode 100644 new mode 100755 diff --git a/test/controllers/microposts_controller_test.rb b/test/controllers/microposts_controller_test.rb new file mode 100755 index 0000000..be8f376 --- /dev/null +++ b/test/controllers/microposts_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class MicropostsControllerTest < ActionController::TestCase + setup do + @micropost = microposts(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:microposts) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create micropost" do + assert_difference('Micropost.count') do + post :create, micropost: { content: @micropost.content, user_id: @micropost.user_id } + end + + assert_redirected_to micropost_path(assigns(:micropost)) + end + + test "should show micropost" do + get :show, id: @micropost + assert_response :success + end + + test "should get edit" do + get :edit, id: @micropost + assert_response :success + end + + test "should update micropost" do + patch :update, id: @micropost, micropost: { content: @micropost.content, user_id: @micropost.user_id } + assert_redirected_to micropost_path(assigns(:micropost)) + end + + test "should destroy micropost" do + assert_difference('Micropost.count', -1) do + delete :destroy, id: @micropost + end + + assert_redirected_to microposts_path + end +end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100755 index 0000000..91b2342 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class UsersControllerTest < ActionController::TestCase + setup do + @user = users(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:users) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create user" do + assert_difference('User.count') do + post :create, user: { email: @user.email, name: @user.name } + end + + assert_redirected_to user_path(assigns(:user)) + end + + test "should show user" do + get :show, id: @user + assert_response :success + end + + test "should get edit" do + get :edit, id: @user + assert_response :success + end + + test "should update user" do + patch :update, id: @user, user: { email: @user.email, name: @user.name } + assert_redirected_to user_path(assigns(:user)) + end + + test "should destroy user" do + assert_difference('User.count', -1) do + delete :destroy, id: @user + end + + assert_redirected_to users_path + end +end diff --git a/test/fixtures/.keep b/test/fixtures/.keep old mode 100644 new mode 100755 diff --git a/test/fixtures/microposts.yml b/test/fixtures/microposts.yml new file mode 100755 index 0000000..dcb4d1b --- /dev/null +++ b/test/fixtures/microposts.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + content: MyString + user_id: 1 + +two: + content: MyString + user_id: 1 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100755 index 0000000..5dc4ddf --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + email: MyString + +two: + name: MyString + email: MyString diff --git a/test/helpers/.keep b/test/helpers/.keep old mode 100644 new mode 100755 diff --git a/test/helpers/microposts_helper_test.rb b/test/helpers/microposts_helper_test.rb new file mode 100755 index 0000000..cff90b5 --- /dev/null +++ b/test/helpers/microposts_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class MicropostsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/users_helper_test.rb b/test/helpers/users_helper_test.rb new file mode 100755 index 0000000..96af37a --- /dev/null +++ b/test/helpers/users_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class UsersHelperTest < ActionView::TestCase +end diff --git a/test/integration/.keep b/test/integration/.keep old mode 100644 new mode 100755 diff --git a/test/mailers/.keep b/test/mailers/.keep old mode 100644 new mode 100755 diff --git a/test/models/.keep b/test/models/.keep old mode 100644 new mode 100755 diff --git a/test/models/micropost_test.rb b/test/models/micropost_test.rb new file mode 100755 index 0000000..def8e93 --- /dev/null +++ b/test/models/micropost_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MicropostTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100755 index 0000000..82f61e0 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/test_helper.rb b/test/test_helper.rb old mode 100644 new mode 100755 diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep old mode 100644 new mode 100755 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep old mode 100644 new mode 100755