From a9bb3ff70d0737fb37ac200ad11885729c070609 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 24 Jul 2014 11:58:08 +0700 Subject: [PATCH 1/5] added project management models --- app/models/comment.rb | 3 ++ app/models/project.rb | 2 ++ app/models/task.rb | 3 ++ db/migrate/20140724041417_create_projects.rb | 10 +++++++ db/migrate/20140724041707_create_tasks.rb | 11 ++++++++ db/migrate/20140724041728_create_comments.rb | 10 +++++++ db/schema.rb | 29 +++++++++++++++++++- spec/models/comment_spec.rb | 5 ++++ spec/models/project_spec.rb | 5 ++++ spec/models/task_spec.rb | 5 ++++ 10 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 app/models/comment.rb create mode 100644 app/models/project.rb create mode 100644 app/models/task.rb create mode 100644 db/migrate/20140724041417_create_projects.rb create mode 100644 db/migrate/20140724041707_create_tasks.rb create mode 100644 db/migrate/20140724041728_create_comments.rb create mode 100644 spec/models/comment_spec.rb create mode 100644 spec/models/project_spec.rb create mode 100644 spec/models/task_spec.rb diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..edb397e --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ActiveRecord::Base + belongs_to :commentable, polymorphic: true +end diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 0000000..5bc7957 --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,2 @@ +class Project < ActiveRecord::Base +end diff --git a/app/models/task.rb b/app/models/task.rb new file mode 100644 index 0000000..5c58542 --- /dev/null +++ b/app/models/task.rb @@ -0,0 +1,3 @@ +class Task < ActiveRecord::Base + belongs_to :user +end diff --git a/db/migrate/20140724041417_create_projects.rb b/db/migrate/20140724041417_create_projects.rb new file mode 100644 index 0000000..8c93aba --- /dev/null +++ b/db/migrate/20140724041417_create_projects.rb @@ -0,0 +1,10 @@ +class CreateProjects < ActiveRecord::Migration + def change + create_table :projects do |t| + t.string :name + t.string :description + + t.timestamps + end + end +end diff --git a/db/migrate/20140724041707_create_tasks.rb b/db/migrate/20140724041707_create_tasks.rb new file mode 100644 index 0000000..8d1207f --- /dev/null +++ b/db/migrate/20140724041707_create_tasks.rb @@ -0,0 +1,11 @@ +class CreateTasks < ActiveRecord::Migration + def change + create_table :tasks do |t| + t.text :name + t.references :user, index: true + t.references :project + + t.timestamps + end + end +end diff --git a/db/migrate/20140724041728_create_comments.rb b/db/migrate/20140724041728_create_comments.rb new file mode 100644 index 0000000..f1f328f --- /dev/null +++ b/db/migrate/20140724041728_create_comments.rb @@ -0,0 +1,10 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.text :body + t.references :commentable, index: true, polymorphic: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3010b2d..deb8dac 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,12 +11,22 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140703173037) do +ActiveRecord::Schema.define(version: 20140724041728) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "hstore" + create_table "comments", force: true do |t| + t.text "body" + t.integer "commentable_id" + t.string "commentable_type" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree + create_table "configurables", force: true do |t| t.string "name" t.string "slug" @@ -56,6 +66,13 @@ add_index "line_items", ["invoice_id"], name: "index_line_items_on_invoice_id", using: :btree + create_table "projects", force: true do |t| + t.string "name" + t.string "description" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "settings", force: true do |t| t.string "company" t.text "address" @@ -69,6 +86,16 @@ t.hstore "invoice", default: {} end + create_table "tasks", force: true do |t| + t.text "name" + t.integer "user_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "tasks", ["user_id"], name: "index_tasks_on_user_id", using: :btree + create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb new file mode 100644 index 0000000..16c4a46 --- /dev/null +++ b/spec/models/comment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Comment, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb new file mode 100644 index 0000000..cd90eec --- /dev/null +++ b/spec/models/project_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Project, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb new file mode 100644 index 0000000..2c17e87 --- /dev/null +++ b/spec/models/task_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Task, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 939939d31e56bd53bb1911a4cc62f6755dda0c88 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 24 Jul 2014 12:02:45 +0700 Subject: [PATCH 2/5] added test for projects controller --- app/assets/javascripts/projects.js.coffee | 3 +++ app/assets/stylesheets/projects.css.scss | 3 +++ app/controllers/projects_controller.rb | 5 +++++ app/helpers/projects_helper.rb | 2 ++ config/routes.rb | 8 ++++++++ spec/controllers/projects_controller_spec.rb | 14 ++++++++++++++ spec/fixtures/projects.yml | 3 +++ spec/fixtures/tasks.yml | 7 +++++++ spec/helpers/projects_helper_spec.rb | 15 +++++++++++++++ 9 files changed, 60 insertions(+) create mode 100644 app/assets/javascripts/projects.js.coffee create mode 100644 app/assets/stylesheets/projects.css.scss create mode 100644 app/controllers/projects_controller.rb create mode 100644 app/helpers/projects_helper.rb create mode 100644 spec/controllers/projects_controller_spec.rb create mode 100644 spec/fixtures/projects.yml create mode 100644 spec/fixtures/tasks.yml create mode 100644 spec/helpers/projects_helper_spec.rb diff --git a/app/assets/javascripts/projects.js.coffee b/app/assets/javascripts/projects.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/projects.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/projects.css.scss b/app/assets/stylesheets/projects.css.scss new file mode 100644 index 0000000..d019266 --- /dev/null +++ b/app/assets/stylesheets/projects.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the projects 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/projects_controller.rb b/app/controllers/projects_controller.rb new file mode 100644 index 0000000..7daa6a6 --- /dev/null +++ b/app/controllers/projects_controller.rb @@ -0,0 +1,5 @@ +class ProjectsController < ApplicationController + def index + @projects = Project.all + end +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb new file mode 100644 index 0000000..db5c5ce --- /dev/null +++ b/app/helpers/projects_helper.rb @@ -0,0 +1,2 @@ +module ProjectsHelper +end diff --git a/config/routes.rb b/config/routes.rb index c5eab7f..88127f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,14 @@ resources :contacts + resources :projects do + resources :tasks + end + + resources :tasks do + resources :comments + end + resources :settings root to: "contacts#index" diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb new file mode 100644 index 0000000..39bd44f --- /dev/null +++ b/spec/controllers/projects_controller_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe ProjectsController, :type => :controller do + fixtures :projects + + let(:project) { projects(:project_1) } + + describe "GET index" do + it "should be success" do + get :index + expect(response.status).to eq(200) + end + end +end diff --git a/spec/fixtures/projects.yml b/spec/fixtures/projects.yml new file mode 100644 index 0000000..5f43d11 --- /dev/null +++ b/spec/fixtures/projects.yml @@ -0,0 +1,3 @@ +project_1: + name: "Test Project" + description: "Project used for the test suite" \ No newline at end of file diff --git a/spec/fixtures/tasks.yml b/spec/fixtures/tasks.yml new file mode 100644 index 0000000..46c14df --- /dev/null +++ b/spec/fixtures/tasks.yml @@ -0,0 +1,7 @@ +task_1: + name: "Test Task" + project: project_1 + +task_2: + name: "Test task 2" + project: project_1 \ No newline at end of file diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb new file mode 100644 index 0000000..74b7b91 --- /dev/null +++ b/spec/helpers/projects_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ProjectsHelper. For example: +# +# describe ProjectsHelper 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 ProjectsHelper, :type => :helper do + pending "add some examples to (or delete) #{__FILE__}" +end From 0879d0e0b6f50406adf612d96aa6e6db6e2df180 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 24 Jul 2014 12:38:06 +0700 Subject: [PATCH 3/5] added project management feature spec --- Gemfile | 2 +- Gemfile.lock | 56 +++++++++++------------ spec/features/projects_management_spec.rb | 1 + 3 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 spec/features/projects_management_spec.rb diff --git a/Gemfile b/Gemfile index 805ee6e..6bf280e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.1.2' +gem 'rails', '4.1.4' # Use postgresql as the database for Active Record gem 'pg' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index a198459..d088e9b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,27 +18,27 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.2) - actionpack (= 4.1.2) - actionview (= 4.1.2) + actionmailer (4.1.4) + actionpack (= 4.1.4) + actionview (= 4.1.4) mail (~> 2.5.4) - actionpack (4.1.2) - actionview (= 4.1.2) - activesupport (= 4.1.2) + actionpack (4.1.4) + actionview (= 4.1.4) + activesupport (= 4.1.4) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.2) - activesupport (= 4.1.2) + actionview (4.1.4) + activesupport (= 4.1.4) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.2) - activesupport (= 4.1.2) + activemodel (4.1.4) + activesupport (= 4.1.4) builder (~> 3.1) - activerecord (4.1.2) - activemodel (= 4.1.2) - activesupport (= 4.1.2) + activerecord (4.1.4) + activemodel (= 4.1.4) + activesupport (= 4.1.4) arel (~> 5.0.0) - activesupport (4.1.2) + activesupport (4.1.4) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -96,7 +96,7 @@ GEM posix-spawn (~> 0.3.6) hike (1.2.3) hirb (0.7.2) - i18n (0.6.9) + i18n (0.6.11) jbuilder (2.1.1) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) @@ -110,7 +110,7 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) - minitest (5.3.5) + minitest (5.4.0) monetize (0.3.0) money (~> 6.1.0.beta1) money (6.1.1) @@ -154,19 +154,19 @@ GEM rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (4.1.2) - actionmailer (= 4.1.2) - actionpack (= 4.1.2) - actionview (= 4.1.2) - activemodel (= 4.1.2) - activerecord (= 4.1.2) - activesupport (= 4.1.2) + rails (4.1.4) + actionmailer (= 4.1.4) + actionpack (= 4.1.4) + actionview (= 4.1.4) + activemodel (= 4.1.4) + activerecord (= 4.1.4) + activesupport (= 4.1.4) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.2) + railties (= 4.1.4) sprockets-rails (~> 2.0) - railties (4.1.2) - actionpack (= 4.1.2) - activesupport (= 4.1.2) + railties (4.1.4) + actionpack (= 4.1.4) + activesupport (= 4.1.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) @@ -246,7 +246,7 @@ DEPENDENCIES pg pry-byebug quiet_assets - rails (= 4.1.2) + rails (= 4.1.4) rspec-rails (~> 3.0.0) sass-rails (~> 4.0.3) sdoc (~> 0.4.0) diff --git a/spec/features/projects_management_spec.rb b/spec/features/projects_management_spec.rb new file mode 100644 index 0000000..d034ba6 --- /dev/null +++ b/spec/features/projects_management_spec.rb @@ -0,0 +1 @@ +require 'rails_helper' \ No newline at end of file From d11debaba326e35ca36951394a4636c0712a7263 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 24 Jul 2014 12:42:09 +0700 Subject: [PATCH 4/5] added basic project content page --- app/views/projects/_project.html.erb | 3 +++ app/views/projects/index.html.erb | 1 + spec/features/application_layout_spec.rb | 15 +++++++++++++++ spec/features/projects_management_spec.rb | 14 +++++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/views/projects/_project.html.erb create mode 100644 app/views/projects/index.html.erb create mode 100644 spec/features/application_layout_spec.rb diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb new file mode 100644 index 0000000..99e19e3 --- /dev/null +++ b/app/views/projects/_project.html.erb @@ -0,0 +1,3 @@ +<%= div_for project do %> +

<%= project.name %>

+<% end %> \ No newline at end of file diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb new file mode 100644 index 0000000..33236d7 --- /dev/null +++ b/app/views/projects/index.html.erb @@ -0,0 +1 @@ +<%= render @projects %> \ No newline at end of file diff --git a/spec/features/application_layout_spec.rb b/spec/features/application_layout_spec.rb new file mode 100644 index 0000000..dc1d2d5 --- /dev/null +++ b/spec/features/application_layout_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +feature "Application layout" do + + scenario "User should see main nav" do + visit root_path + + expect(page).to have_text("Contacts") + expect(page).to have_text("Invoices") + expect(page).to have_text("Projects") + expect(page).to have_text("Team") + expect(page).to have_text("Settings") + end + +end \ No newline at end of file diff --git a/spec/features/projects_management_spec.rb b/spec/features/projects_management_spec.rb index d034ba6..8b232a5 100644 --- a/spec/features/projects_management_spec.rb +++ b/spec/features/projects_management_spec.rb @@ -1 +1,13 @@ -require 'rails_helper' \ No newline at end of file +require 'rails_helper' + +feature "Project Management" do + fixtures :projects + + let(:project) { projects(:project_1) } + + scenario "Project list" do + visit projects_path + + expect(page).to have_content(project.name) + end +end \ No newline at end of file From b1029e6e8662fa32a2b462259e5db4d6f1bcd2f7 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 24 Jul 2014 12:46:57 +0700 Subject: [PATCH 5/5] added codeship badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 77a04fd..2156565 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ paymii ====== +[ ![Codeship Status for codemy/paymii](https://codeship.io/projects/a8cff080-f523-0131-fff6-126686c2871f/status)](https://codeship.io/projects/28254) + Invoicing Application used as a demo for Rails from Scratch Course