Skip to content
Browse files

resolved confrict

  • Loading branch information...
2 parents 4099624 + 3a87896 commit 0e9b3eecf0e640471b8ecff26d20fde836c2d310 teppei machida committed
Showing with 1,528 additions and 667 deletions.
  1. +3 −1 .gitignore
  2. +22 −1 Gemfile
  3. +105 −39 Gemfile.lock
  4. 0 app/assets/images/{dummy.png → fallback/default.png}
  5. BIN app/assets/images/fallback/thumb_default.png
  6. 0 app/assets/javascripts/{activities.js.coffee → comments.js.coffee}
  7. +2 −2 app/assets/javascripts/parties.js.coffee
  8. +36 −1 app/assets/stylesheets/sass/parties.css.sass
  9. +0 −76 app/controllers/activities_controller.rb
  10. +76 −0 app/controllers/comments_controller.rb
  11. +0 −2 app/helpers/activities_helper.rb
  12. +2 −0 app/helpers/comments_helper.rb
  13. +0 −6 app/models/activity.rb
  14. +19 −0 app/models/authentication.rb
  15. +18 −0 app/models/comment.rb
  16. +21 −3 app/models/join.rb
  17. +14 −2 app/models/party.rb
  18. +51 −5 app/models/task.rb
  19. +34 −5 app/models/user.rb
  20. +52 −0 app/uploaders/image_uploader.rb
  21. +0 −7 app/views/activities/_activity.html.haml
  22. +0 −2 app/views/activities/create.js.erb
  23. +0 −1 app/views/activities/destroy.js.erb
  24. +0 −6 app/views/activities/edit.html.erb
  25. +0 −25 app/views/activities/index.html.erb
  26. +0 −5 app/views/activities/new.html.erb
  27. +0 −15 app/views/activities/show.html.erb
  28. +7 −0 app/views/comments/_comment.html.haml
  29. +4 −4 app/views/{activities → comments}/_form.html.erb
  30. +2 −0 app/views/comments/create.js.erb
  31. +1 −0 app/views/comments/destroy.js.erb
  32. +6 −0 app/views/comments/edit.html.erb
  33. +25 −0 app/views/comments/index.html.erb
  34. +5 −0 app/views/comments/new.html.erb
  35. +15 −0 app/views/comments/show.html.erb
  36. +1 −1 app/views/parties/index.html.haml
  37. +2 −2 app/views/parties/show.html.haml
  38. +10 −1 app/views/settings/_form.html.haml
  39. +12 −1 app/views/tasks/_task.html.haml
  40. +2 −3 config/initializers/devise.rb
  41. +1 −1 config/routes.rb
  42. +2 −2 db/migrate/{20120519100019_create_activities.rb → 20120519100019_create_comments.rb}
  43. +8 −8 db/schema.rb
  44. +12 −12 public/parties_show.html
  45. +164 −0 spec/controllers/comments_controller_spec.rb
  46. +164 −0 spec/controllers/joins_controller_spec.rb
  47. +164 −0 spec/controllers/parties_controller_spec.rb
  48. +167 −0 spec/controllers/tasks_controller_spec.rb
  49. +27 −0 spec/controllers/users_controller_spec.rb
  50. +9 −0 spec/factories/comments.rb
  51. +13 −0 spec/factories/joins.rb
  52. +9 −0 spec/factories/parties.rb
  53. +12 −0 spec/factories/tasks.rb
  54. +10 −0 spec/factories/users.rb
  55. +10 −0 spec/models/comment_spec.rb
  56. +17 −0 spec/models/join_spec.rb
  57. +23 −0 spec/models/party_spec.rb
  58. +62 −0 spec/models/task_spec.rb
  59. +20 −0 spec/models/user_spec.rb
  60. +11 −0 spec/requests/comments_spec.rb
  61. +11 −0 spec/requests/joins_spec.rb
  62. +11 −0 spec/requests/parties_spec.rb
  63. +11 −0 spec/requests/tasks_spec.rb
  64. +11 −0 spec/requests/users_spec.rb
  65. +32 −0 spec/spec_helper.rb
  66. 0 test/fixtures/.gitkeep
  67. +0 −9 test/fixtures/activities.yml
  68. +0 −7 test/fixtures/authentications.yml
  69. +0 −9 test/fixtures/joins.yml
  70. +0 −11 test/fixtures/parties.yml
  71. +0 −15 test/fixtures/tasks.yml
  72. +0 −9 test/fixtures/users.yml
  73. 0 test/functional/.gitkeep
  74. +0 −49 test/functional/activities_controller_test.rb
  75. +0 −49 test/functional/joins_controller_test.rb
  76. +0 −49 test/functional/parties_controller_test.rb
  77. +0 −14 test/functional/sessions_controller_test.rb
  78. +0 −14 test/functional/settings_controller_test.rb
  79. +0 −49 test/functional/tasks_controller_test.rb
  80. +0 −49 test/functional/users_controller_test.rb
  81. 0 test/integration/.gitkeep
  82. +0 −12 test/performance/browsing_test.rb
  83. +0 −13 test/test_helper.rb
  84. 0 test/unit/.gitkeep
  85. +0 −7 test/unit/activity_test.rb
  86. +0 −7 test/unit/authentication_test.rb
  87. +0 −4 test/unit/helpers/activities_helper_test.rb
  88. +0 −4 test/unit/helpers/joins_helper_test.rb
  89. +0 −4 test/unit/helpers/parties_helper_test.rb
  90. +0 −4 test/unit/helpers/sessions_helper_test.rb
  91. +0 −4 test/unit/helpers/settings_helper_test.rb
  92. +0 −4 test/unit/helpers/tasks_helper_test.rb
  93. +0 −4 test/unit/helpers/users_helper_test.rb
  94. +0 −7 test/unit/join_test.rb
  95. +0 −7 test/unit/party_test.rb
  96. +0 −7 test/unit/task_test.rb
  97. +0 −7 test/unit/user_test.rb
View
4 .gitignore
@@ -15,6 +15,8 @@
/tmp
.rvmrc
+.rspec
.sass-cache/
-public/assets/
+public/assets/
+public/uploads/
View
23 Gemfile
@@ -25,13 +25,34 @@ gem 'jquery-rails'
gem 'best_in_place'
gem 'devise'
-gem 'oa-oauth', :require => "omniauth/oauth"
+#gem 'oa-oauth', :require => "omniauth/oauth"
+
+gem 'carrierwave'
+gem "rmagick"
group :development do
gem 'sqlite3'
+ gem 'annotate', '~> 2.4.1.beta'
gem 'erb2haml'
end
+group :development, :test do
+ gem 'rspec-rails', '2.10.0'
+ gem 'guard-rspec', '0.5.5'
+ gem 'guard-spork', '0.3.2'
+ gem 'spork', '0.9.0'
+end
+
+group :test do
+ gem 'capybara', '1.1.2'
+ gem 'rb-fsevent', '0.4.3.1', require: false
+ gem 'growl', '1.0.3'
+ gem 'factory_girl_rails', '1.4.0'
+ gem 'cucumber-rails', '1.2.1', require: false
+ gem 'database_cleaner', '0.7.0'
+ gem 'shoulda-matchers'
+end
+
group :production do
gem 'pg'
end
View
144 Gemfile.lock
@@ -29,12 +29,25 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.8)
+ annotate (2.4.1.beta1)
arel (3.0.2)
bcrypt-ruby (3.0.1)
- best_in_place (1.0.6)
+ best_in_place (1.1.2)
jquery-rails
rails (~> 3.1)
builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ carrierwave (0.6.2)
+ activemodel (>= 3.2.0)
+ activesupport (>= 3.2.0)
+ childprocess (0.3.3)
+ ffi (~> 1.0.6)
chunky_png (1.2.5)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -42,61 +55,75 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.3.1)
- compass (0.12.1)
+ coffee-script-source (1.3.3)
+ compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
- compass-rails (1.0.1)
- compass (~> 0.12.0)
- devise (1.4.5)
+ compass-rails (1.0.3)
+ compass (>= 0.12.2, < 0.14)
+ cucumber (1.2.1)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
+ json (>= 1.4.6)
+ cucumber-rails (1.2.1)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.1.3)
+ nokogiri (>= 1.5.0)
+ database_cleaner (0.7.0)
+ devise (2.1.2)
bcrypt-ruby (~> 3.0)
- orm_adapter (~> 0.0.3)
- warden (~> 1.0.3)
+ orm_adapter (~> 0.1)
+ railties (~> 3.1)
+ warden (~> 1.2.1)
+ diff-lcs (1.1.3)
erb2haml (0.1.2)
haml
hpricot
ruby_parser
erubis (2.7.0)
- execjs (1.3.1)
+ execjs (1.4.0)
multi_json (~> 1.0)
- faraday (0.6.1)
- addressable (~> 2.2.4)
- multipart-post (~> 1.1.0)
- rack (>= 1.1.0, < 2)
+ factory_girl (2.3.2)
+ activesupport
+ factory_girl_rails (1.4.0)
+ factory_girl (~> 2.3.0)
+ railties (>= 3.0.0)
+ ffi (1.0.11)
fssm (0.2.9)
- haml (3.1.4)
+ gherkin (2.11.1)
+ json (>= 1.4.6)
+ growl (1.0.3)
+ guard (1.0.3)
+ ffi (>= 0.5.0)
+ thor (>= 0.14.6)
+ guard-rspec (0.5.5)
+ guard (>= 0.8.4)
+ guard-spork (0.3.2)
+ guard (>= 0.8.4)
+ spork (>= 0.8.4)
+ haml (3.1.6)
hike (1.2.1)
hpricot (0.8.6)
i18n (0.6.0)
- journey (1.0.3)
+ journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
- json (1.7.0)
+ json (1.7.3)
libv8 (3.3.10.4)
+ libwebsocket (0.1.3)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.18)
- multi_json (1.3.4)
- multipart-post (1.1.5)
- nokogiri (1.4.7)
- oa-core (0.2.4)
- oa-oauth (0.2.4)
- faraday (~> 0.6.1)
- multi_json (>= 0.0.5)
- nokogiri (~> 1.4.2)
- oa-core (= 0.2.4)
- oauth (~> 0.4.0)
- oauth2 (~> 0.4.1)
- oauth (0.4.6)
- oauth2 (0.4.1)
- faraday (~> 0.6.1)
- multi_json (>= 0.0.5)
- orm_adapter (0.0.5)
- pg (0.13.2)
+ mime-types (1.19)
+ multi_json (1.3.6)
+ nokogiri (1.5.5)
+ orm_adapter (0.3.0)
+ pg (0.14.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -121,16 +148,40 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
+ rb-fsevent (0.4.3.1)
rdoc (3.12)
json (~> 1.4)
+ rmagick (2.13.1)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.1)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
+ rspec-rails (2.10.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.10.0)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
- sass (3.1.16)
+ rubyzip (0.9.9)
+ sass (3.1.19)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ selenium-webdriver (2.24.0)
+ childprocess (>= 0.2.5)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
sexp_processor (3.2.0)
+ shoulda-matchers (1.2.0)
+ activesupport (>= 3.0.0)
+ spork (0.9.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -144,26 +195,41 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
- uglifier (1.2.4)
+ uglifier (1.2.6)
execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
- warden (1.0.5)
+ multi_json (~> 1.3)
+ warden (1.2.1)
rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ annotate (~> 2.4.1.beta)
best_in_place
+ capybara (= 1.1.2)
+ carrierwave
coffee-rails (~> 3.2.1)
compass-rails
+ cucumber-rails (= 1.2.1)
+ database_cleaner (= 0.7.0)
devise
erb2haml
+ factory_girl_rails (= 1.4.0)
+ growl (= 1.0.3)
+ guard-rspec (= 0.5.5)
+ guard-spork (= 0.3.2)
jquery-rails
- oa-oauth
pg
rails (= 3.2.3)
+ rb-fsevent (= 0.4.3.1)
+ rmagick
+ rspec-rails (= 2.10.0)
sass-rails (~> 3.2.3)
+ shoulda-matchers
+ spork (= 0.9.0)
sqlite3
therubyracer
uglifier (>= 1.0.3)
View
0 app/assets/images/dummy.png → app/assets/images/fallback/default.png
File renamed without changes
View
BIN app/assets/images/fallback/thumb_default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 app/assets/javascripts/activities.js.coffee → app/assets/javascripts/comments.js.coffee
File renamed without changes.
View
4 app/assets/javascripts/parties.js.coffee
@@ -18,7 +18,7 @@ $ ->
$(".member .header .selectstate").toggle()
$(".doing").click ->
$(".current .actions").toggle()
- $(".activities .label").click ->
- $(".activities ul").toggle()
+ $(".comments .label").click ->
+ $(".comments ul").toggle()
$("#notice").css "left", $(window).width() / 2 - $("#notice").width() / 2
$("#notice").delay(2000).fadeOut "slow"
View
37 app/assets/stylesheets/sass/parties.css.sass
@@ -239,6 +239,41 @@ body.parties_show
.activities
+activities
+ .comments
+ clear: both
+ +clearfix
+ .add
+ padding: 10px 10px 0 10px
+ ul
+ li
+ +clearfix
+ border-bottom: dotted #666 1px
+ display: block
+ padding: 14px 10px
+ &:first-child
+ padding: 14px 10px
+ &:last-child
+ border: none
+ .icon
+ float: left
+ padding: 0 8px 0 0
+ a
+ width: 36px
+ height: 36px
+ padding: 3px
+ background: rgba(0, 0, 0, .2)
+ +border-radius(21px)
+ display: block
+ +box-shadow(#495051 0 1px 0)
+ img
+ width: 36px
+ height: auto
+ +border-radius(18px)
+ p
+ font-size: 13px
+ line-height: 1.6
+
+>>>>>>> 3a87896a141829a5ffa448b42fb14071609b7eec
.backlog
clear: both
+clearfix
@@ -414,4 +449,4 @@ body.parties_show
display: block
float: left
.activities
- +activities
+ +activities
View
76 app/controllers/activities_controller.rb
@@ -1,76 +0,0 @@
-class ActivitiesController < ApplicationController
- before_filter :authenticate_user!
- respond_to :html, :json, :js
-
- # GET /activities
- # GET /activities.json
- def index
- @activities = Activity.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @activities }
- end
- end
-
- # GET /activities/1
- # GET /activities/1.json
- def show
- @activity = Activity.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @activity }
- end
- end
-
- # GET /activities/new
- # GET /activities/new.json
- def new
- @activity = Activity.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @activity }
- end
- end
-
- # GET /activities/1/edit
- def edit
- @activity = Activity.find(params[:id])
- end
-
- # POST /activities
- # POST /activities.json
- def create
- @activity = current_user.activities.build
- @activity.task_id = params[:task_id]
- @activity.content = params[:content]
- @activity.save
- respond_with @activity
- end
-
- # PUT /activities/1
- # PUT /activities/1.json
- def update
- @activity = Activity.find(params[:id])
-
- respond_to do |format|
- if @activity.update_attributes(params[:activity])
- format.html { redirect_to @activity, notice: 'Activity was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @activity.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /activities/1
- # DELETE /activities/1.json
- def destroy
- @activity = Activity.find(params[:id])
- @activity.destroy
- respond_with @activity
- end
-end
View
76 app/controllers/comments_controller.rb
@@ -0,0 +1,76 @@
+class CommentsController < ApplicationController
+ before_filter :authenticate_user!
+ respond_to :html, :json, :js
+
+ # GET /comments
+ # GET /comments.json
+ def index
+ @comments = Comment.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @comments }
+ end
+ end
+
+ # GET /comments/1
+ # GET /comments/1.json
+ def show
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/new
+ # GET /comments/new.json
+ def new
+ @comment = Comment.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/1/edit
+ def edit
+ @comment = Comment.find(params[:id])
+ end
+
+ # POST /comments
+ # POST /comments.json
+ def create
+ @comment = current_user.comments.build
+ @comment.task_id = params[:task_id]
+ @comment.content = params[:content]
+ @comment.save
+ respond_with @comment
+ end
+
+ # PUT /comments/1
+ # PUT /comments/1.json
+ def update
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /comments/1
+ # DELETE /comments/1.json
+ def destroy
+ @comment = Comment.find(params[:id])
+ @comment.destroy
+ respond_with @comment
+ end
+end
View
2 app/helpers/activities_helper.rb
@@ -1,2 +0,0 @@
-module ActivitiesHelper
-end
View
2 app/helpers/comments_helper.rb
@@ -0,0 +1,2 @@
+module CommentsHelper
+end
View
6 app/models/activity.rb
@@ -1,6 +0,0 @@
-class Activity < ActiveRecord::Base
- attr_accessible :content, :task_id, :user_id
-
- belongs_to :task
- belongs_to :user
-end
View
19 app/models/authentication.rb
@@ -1,3 +1,22 @@
+# == Schema Information
+#
+# Table name: authentications
+#
+# id :integer not null, primary key
+# user_id :integer
+# provider :string(255)
+# uid :string(255)
+# screen_name :string(255)
+# access_token :string(255)
+# access_secret :string(255)
+# bio :string(255)
+# image_url :string(255)
+# web_url :string(255)
+# last_tid :string(255)
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
class Authentication < ActiveRecord::Base
attr_accessible :user_id, :provider, :uid, :screen_name, :access_token, :access_secret, :bio, :image_url, :web_url, :last_tid
View
18 app/models/comment.rb
@@ -0,0 +1,18 @@
+# == Schema Information
+#
+# Table name: comments
+#
+# id :integer not null, primary key
+# task_id :integer
+# user_id :integer
+# content :text
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
+class Comment < ActiveRecord::Base
+ attr_accessible :task_id, :user_id, :content
+
+ belongs_to :user
+ belongs_to :task
+end
View
24 app/models/join.rb
@@ -1,10 +1,28 @@
# encoding: utf-8
+
+# == Schema Information
+#
+# Table name: joins
+#
+# id :integer not null, primary key
+# user_id :integer
+# party_id :integer
+# state :string(255) default("chore")
+# started_at :datetime
+# finished_at :datetime
+# end_hour :integer default(0)
+# end_min :integer default(0)
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
class Join < ActiveRecord::Base
- attr_accessible :party_id, :user_id, :state, :end_hour, :end_min, :help
- belongs_to :party
+ attr_accessible :user_id, :party_id, :state, :started_at, :finished_at, :end_hour, :end_min
+
belongs_to :user
+ belongs_to :party
- validates :party_id, :user_id, :presence => true
+ validates :user_id, :party_id, :presence => true
validates :party_id, :uniqueness => {:scope => :user_id}
STATE = [
View
16 app/models/party.rb
@@ -1,9 +1,21 @@
+# == Schema Information
+#
+# Table name: parties
+#
+# id :integer not null, primary key
+# name :string(255)
+# description :text
+# user_id :integer
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
class Party < ActiveRecord::Base
- attr_accessible :description, :name, :user_id, :member_tokens
+ attr_accessible :name, :description, :user_id, :member_tokens
+ belongs_to :user
has_many :joins
has_many :members, :through => :joins, :source => :user
- belongs_to :user
attr_reader :member_tokens
View
56 app/models/task.rb
@@ -1,22 +1,68 @@
+# == Schema Information
+#
+# Table name: tasks
+#
+# id :integer not null, primary key
+# user_id :integer
+# party_id :integer
+# content :text
+# state :string(255)
+# help :boolean
+# started_at :datetime
+# finished_at :datetime
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
class Task < ActiveRecord::Base
- attr_accessible :content, :finished_at, :started_at, :state, :user_id
+ attr_accessible :user_id, :party_id, :content, :state, :help, :started_at, :finished_at
+
belongs_to :user
belongs_to :party
- has_many :activities
+ has_many :comments
- validates :content, :user_id, :presence => true
+ validates :user_id, :content, :presence => true
STATE = %w(current backlog done)
+ def start
+ unless Task.current(party_id).exists?
+ self.state = "current"
+ self.started_at = Time.now
+ save!
+ end
+ end
+
+ def hold
+ if state == "current"
+ self.state = "backlog"
+ save!
+ end
+ end
+
+ def finish
+ if state == "current"
+ self.state = "done"
+ save!
+ end
+ end
+
+ def redo
+ if state == "done"
+ self.state = "backlog"
+ save!
+ end
+ end
+
def self.current(party_id)
where(state: "current", party_id: party_id)
end
def self.backlog(party_id)
- where(state: "backlog", party_id: party_id).order("created_at desc")
+ where(state: "backlog", party_id: party_id).order("updated_at desc")
end
def self.done(party_id)
- where(state: "done", party_id: party_id).order("created_at desc")
+ where(state: "done", party_id: party_id).order("updated_at desc")
end
end
View
39 app/models/user.rb
@@ -1,16 +1,45 @@
class User < ActiveRecord::Base
- attr_accessible :id, :image, :name, :email, :password, :remember_me, :password_confirmation
+ attr_accessible :id, :image, :remove_image, :name, :email, :password, :remember_me, :password_confirmation
- has_many :authentications
+# has_many :authentications
has_many :parties
has_many :joins
has_many :invited_parties, :through => :joins, :source => :party
has_many :tasks
- has_many :activities
+ has_many :comments
validates :name, :presence => true
- validates :email, :password, :presence => true, :on => :create
+ validates :password, :presence => true, :on => :create
# validates :uid, :uniqueness => {:scope => :provider}
- devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :omniauthable
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
+
+ mount_uploader :image, ImageUploader
+
+ protected
+ def password_required?
+ false
+ end
end
+
+# == Schema Information
+#
+# Table name: users
+#
+# id :integer not null, primary key
+# name :string(255)
+# image :string(255)
+# email :string(255) default(""), not null
+# encrypted_password :string(128) default(""), not null
+# reset_password_token :string(255)
+# reset_password_sent_at :datetime
+# remember_created_at :datetime
+# sign_in_count :integer default(0)
+# current_sign_in_at :datetime
+# last_sign_in_at :datetime
+# current_sign_in_ip :string(255)
+# last_sign_in_ip :string(255)
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
View
52 app/uploaders/image_uploader.rb
@@ -0,0 +1,52 @@
+# encoding: utf-8
+
+class ImageUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ def default_url
+ "/assets/fallback/" + [version_name, "default.png"].compact.join('_')
+ end
+
+ # Process files as they are uploaded:
+ # process :scale => [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process :scale => [50, 50]
+ # end
+
+ version :thumb do
+ process :resize_to_fill => [50, 50]
+ end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ # def extension_white_list
+ # %w(jpg jpeg gif png)
+ # end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
View
7 app/views/activities/_activity.html.haml
@@ -1,7 +0,0 @@
-= content_tag_for :li, activity, :class => "activity" do
- .icon
- %a{:href => ""}
- = image_tag activity.user.image ? activity.user.image : "dummy.png", alt: activity.user.name, class: "avatar size128"
- %p= nl2br activity.content
- - if user_signed_in? && current_user == activity.user
- %p= link_to "delete", activity_path(activity), :method => :delete, :remote => true
View
2 app/views/activities/create.js.erb
@@ -1,2 +0,0 @@
-$('#<%= dom_id(@activity.task) %> textarea').val("")
-$('#<%= dom_id(@activity.task) %> .activities ul').prepend("<%= j(render @activity) %>").fadeIn()
View
1 app/views/activities/destroy.js.erb
@@ -1 +0,0 @@
-$('#<%= dom_id(@activity) %>').remove().fadeOut()
View
6 app/views/activities/edit.html.erb
@@ -1,6 +0,0 @@
-<h1>Editing activity</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @activity %> |
-<%= link_to 'Back', activities_path %>
View
25 app/views/activities/index.html.erb
@@ -1,25 +0,0 @@
-<h1>Listing activities</h1>
-
-<table>
- <tr>
- <th>User</th>
- <th>Content</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @activities.each do |activity| %>
- <tr>
- <td><%= activity.user_id %></td>
- <td><%= activity.content %></td>
- <td><%= link_to 'Show', activity %></td>
- <td><%= link_to 'Edit', edit_activity_path(activity) %></td>
- <td><%= link_to 'Destroy', activity, confirm: 'Are you sure?', method: :delete %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New Activity', new_activity_path %>
View
5 app/views/activities/new.html.erb
@@ -1,5 +0,0 @@
-<h1>New activity</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', activities_path %>
View
15 app/views/activities/show.html.erb
@@ -1,15 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>User:</b>
- <%= @activity.user_id %>
-</p>
-
-<p>
- <b>Content:</b>
- <%= @activity.content %>
-</p>
-
-
-<%= link_to 'Edit', edit_activity_path(@activity) %> |
-<%= link_to 'Back', activities_path %>
View
7 app/views/comments/_comment.html.haml
@@ -0,0 +1,7 @@
+= content_tag_for :li, comment, :class => "comment" do
+ .icon
+ %a{:href => ""}
+ = image_tag comment.user.image_url(:thumb), alt: comment.user.name, class: "avatar size128"
+ %p= nl2br comment.content
+ - if user_signed_in? && current_user == comment.user
+ %p= link_to "delete", comment_path(comment), :method => :delete, :remote => true
View
8 app/views/activities/_form.html.erb → app/views/comments/_form.html.erb
@@ -1,10 +1,10 @@
-<%= form_for(@activity) do |f| %>
- <% if @activity.errors.any? %>
+<%= form_for(@comment) do |f| %>
+ <% if @comment.errors.any? %>
<div id="error_explanation">
- <h2><%= pluralize(@activity.errors.count, "error") %> prohibited this activity from being saved:</h2>
+ <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
- <% @activity.errors.full_messages.each do |msg| %>
+ <% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
View
2 app/views/comments/create.js.erb
@@ -0,0 +1,2 @@
+$('#<%= dom_id(@comment.task) %> textarea').val("")
+$('#<%= dom_id(@comment.task) %> .comments ul').prepend("<%= j(render @comment) %>").fadeIn()
View
1 app/views/comments/destroy.js.erb
@@ -0,0 +1 @@
+$('#<%= dom_id(@comment) %>').remove().fadeOut()
View
6 app/views/comments/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing comment</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @comment %> |
+<%= link_to 'Back', comments_path %>
View
25 app/views/comments/index.html.erb
@@ -0,0 +1,25 @@
+<h1>Listing comments</h1>
+
+<table>
+ <tr>
+ <th>User</th>
+ <th>Content</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @comments.each do |comment| %>
+ <tr>
+ <td><%= comment.user_id %></td>
+ <td><%= comment.content %></td>
+ <td><%= link_to 'Show', comment %></td>
+ <td><%= link_to 'Edit', edit_comment_path(comment) %></td>
+ <td><%= link_to 'Destroy', comment, confirm: 'Are you sure?', method: :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Comment', new_comment_path %>
View
5 app/views/comments/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New comment</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', comments_path %>
View
15 app/views/comments/show.html.erb
@@ -0,0 +1,15 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>User:</b>
+ <%= @comment.user_id %>
+</p>
+
+<p>
+ <b>Content:</b>
+ <%= @comment.content %>
+</p>
+
+
+<%= link_to 'Edit', edit_comment_path(@comment) %> |
+<%= link_to 'Back', comments_path %>
View
2 app/views/parties/index.html.haml
@@ -13,7 +13,7 @@
- party.members.each do |member|
%li
%a{:href => ""}
- = image_tag member.image ? member.image : "dummy.png"
+ = image_tag member.image_url(:thumb)
.actions
%ul
%li.show= link_to 'Show', party
View
4 app/views/parties/show.html.haml
@@ -30,7 +30,7 @@
- @party.members.each do |member|
= content_tag_for :li, member do
%a{:href => ""}
- = image_tag member.image ? member.image : "dummy.png"
+ = image_tag member.image_url(:thumb)
.times
.now
.remain
@@ -51,7 +51,7 @@
.header
%h1.icon
%a{:href => ""}
- = image_tag member.image ? member.image : "dummy.png"
+ = image_tag member.image_url(:thumb)
.information
%ul
%li.name
View
11 app/views/settings/_form.html.haml
@@ -1,4 +1,4 @@
-= form_for @user, :url => settings_update_path do |f|
+= form_for @user, :url => settings_update_path, :html => {:multipart => true} do |f|
- if @user.errors.any?
#error_explanation
%h2
@@ -28,5 +28,14 @@
%br/
= f.password_field :password_confirmation
+ .field
+ = f.label :image
+ %br/
+ = image_tag @user.image_url(:thumb) if @user.image?
+ %br/
+ = f.file_field :image
+ %br/
+ = f.check_box :remove_image
+
.actions
= f.submit
View
13 app/views/tasks/_task.html.haml
@@ -36,4 +36,15 @@
%p.delete= link_to "delete", party_task_path(@party, task), :method => :delete, :remote => true
- when "done"
- if user_signed_in? && current_user == task.user
- %p.redo= link_to "redo", redo_party_task_path(@party, task), :remote => true
+ %p.redo= link_to "redo", redo_party_task_path(@party, task), :remote => true
+
+ - if user_signed_in?
+ .add
+ = form_tag "/comments", :remote => true do
+ = hidden_field_tag :task_id, task.id
+ = text_area_tag :content, nil, :rows => 3, :cols => 15, :id => "new_comment_#{dom_id(task)}"
+ = submit_tag "new comment"
+ .comments
+ %ul
+ = render task.comments
+>>>>>>> 3a87896a141829a5ffa448b42fb14071609b7eec
View
5 config/initializers/devise.rb
@@ -95,7 +95,7 @@
# If true, uses the password salt as remember token. This should be turned
# to false if you are not using database authenticatable.
- config.use_salt_as_remember_token = true
+ # config.use_salt_as_remember_token = true
# Options to be passed to the created cookie. For instance, you can set
# :secure => true in order to force SSL only cookies.
@@ -111,7 +111,7 @@
# config.email_regexp = /\A[^@]+@[^@]+\z/
# ==> Configuration for :timeoutable
- # The time you want to timeout the user session without activity. After this
+ # The time you want to timeout the user session without comment. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
@@ -198,7 +198,6 @@
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
- config.omniauth :twitter, 'C1jdrQaYUqCJvOjm5DyXfA', 'GCWGOU0QzdNcpaetdIFnZd4rB3npBFv7JzO9BXrRB0'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
View
2 config/routes.rb
@@ -3,7 +3,7 @@
get "settings/edit" => "settings#edit"
put "settings/update" => "settings#update"
- resources :activities
+ resources :comments
resources :joins
View
4 ...grate/20120519100019_create_activities.rb → db/migrate/20120519100019_create_comments.rb
@@ -1,6 +1,6 @@
-class CreateActivities < ActiveRecord::Migration
+class CreateComments < ActiveRecord::Migration
def change
- create_table :activities do |t|
+ create_table :comments do |t|
t.integer :task_id
t.integer :user_id
t.text :content
View
16 db/schema.rb
@@ -13,14 +13,6 @@
ActiveRecord::Schema.define(:version => 20120527040434) do
- create_table "activities", :force => true do |t|
- t.integer "task_id"
- t.integer "user_id"
- t.text "content"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
create_table "authentications", :force => true do |t|
t.integer "user_id"
t.string "provider"
@@ -36,6 +28,14 @@
t.datetime "updated_at", :null => false
end
+ create_table "comments", :force => true do |t|
+ t.integer "task_id"
+ t.integer "user_id"
+ t.text "content"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "joins", :force => true do |t|
t.integer "user_id"
t.integer "party_id"
View
24 public/parties_show.html
@@ -61,9 +61,9 @@ <h1 class="icon">
</ul>
</div>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
@@ -169,9 +169,9 @@ <h1 class="icon">
<div class="doing">
<p>『不思議の国のアリス』(ふしぎのくにのアリス)は、イギリスの数学者にして作家チャールズ・ラトウィッジ・ドジソンが、ルイス・35.685753 , 139.765293</p>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
@@ -274,9 +274,9 @@ <h1 class="icon">
<div class="doing">
<p>『不思議の国のアリス』(ふしぎのくにのアリス)は、イギリスの数学者にして作家チャールズ・ラトウィッジ・ドジソンが、ルイス・35.685753 , 139.765293</p>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
@@ -379,9 +379,9 @@ <h1 class="icon">
<div class="doing">
<p>『不思議の国のアリス』(ふしぎのくにのアリス)は、イギリスの数学者にして作家チャールズ・ラトウィッジ・ドジソンが、ルイス・35.685753 , 139.765293</p>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
@@ -484,9 +484,9 @@ <h1 class="icon">
<div class="doing">
<p>『不思議の国のアリス』(ふしぎのくにのアリス)は、イギリスの数学者にして作家チャールズ・ラトウィッジ・ドジソンが、ルイス・35.685753 , 139.765293</p>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
@@ -589,9 +589,9 @@ <h1 class="icon">
<div class="doing">
<p>『不思議の国のアリス』(ふしぎのくにのアリス)は、イギリスの数学者にして作家チャールズ・ラトウィッジ・ドジソンが、ルイス・35.685753 , 139.765293</p>
</div>
- <div class="activities">
+ <div class="comments">
<div class="label">
- <h2>Activities</h2>
+ <h2>Comments</h2>
</div>
<div class="add">
<form name="form1">
View
164 spec/controllers/comments_controller_spec.rb
@@ -0,0 +1,164 @@
+require 'spec_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.
+
+describe CommentsController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # Comment. As you add validations to Comment, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # 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
+ # CommentsController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all comments as @comments" do
+ comment = Comment.create! valid_attributes
+ get :index, {}, valid_session
+ assigns(:comments).should eq([comment])
+ end
+ end
+
+ describe "GET show" do
+ it "assigns the requested comment as @comment" do
+ comment = Comment.create! valid_attributes
+ get :show, {:id => comment.to_param}, valid_session
+ assigns(:comment).should eq(comment)
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new comment as @comment" do
+ get :new, {}, valid_session
+ assigns(:comment).should be_a_new(Comment)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested comment as @comment" do
+ comment = Comment.create! valid_attributes
+ get :edit, {:id => comment.to_param}, valid_session
+ assigns(:comment).should eq(comment)
+ end
+ end
+
+ describe "POST create" do
+ describe "with valid params" do
+ it "creates a new Comment" do
+ expect {
+ post :create, {:comment => valid_attributes}, valid_session
+ }.to change(Comment, :count).by(1)
+ end
+
+ it "assigns a newly created comment as @comment" do
+ post :create, {:comment => valid_attributes}, valid_session
+ assigns(:comment).should be_a(Comment)
+ assigns(:comment).should be_persisted
+ end
+
+ it "redirects to the created comment" do
+ post :create, {:comment => valid_attributes}, valid_session
+ response.should redirect_to(Comment.last)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns a newly created but unsaved comment as @comment" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Comment.any_instance.stub(:save).and_return(false)
+ post :create, {:comment => {}}, valid_session
+ assigns(:comment).should be_a_new(Comment)
+ end
+
+ it "re-renders the 'new' template" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Comment.any_instance.stub(:save).and_return(false)
+ post :create, {:comment => {}}, valid_session
+ response.should render_template("new")
+ end
+ end
+ end
+
+ describe "PUT update" do
+ describe "with valid params" do
+ it "updates the requested comment" do
+ comment = Comment.create! valid_attributes
+ # Assuming there are no other comments in the database, this
+ # specifies that the Comment created on the previous line
+ # receives the :update_attributes message with whatever params are
+ # submitted in the request.
+ Comment.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, {:id => comment.to_param, :comment => {'these' => 'params'}}, valid_session
+ end
+
+ it "assigns the requested comment as @comment" do
+ comment = Comment.create! valid_attributes
+ put :update, {:id => comment.to_param, :comment => valid_attributes}, valid_session
+ assigns(:comment).should eq(comment)
+ end
+
+ it "redirects to the comment" do
+ comment = Comment.create! valid_attributes
+ put :update, {:id => comment.to_param, :comment => valid_attributes}, valid_session
+ response.should redirect_to(comment)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns the comment as @comment" do
+ comment = Comment.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Comment.any_instance.stub(:save).and_return(false)
+ put :update, {:id => comment.to_param, :comment => {}}, valid_session
+ assigns(:comment).should eq(comment)
+ end
+
+ it "re-renders the 'edit' template" do
+ comment = Comment.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Comment.any_instance.stub(:save).and_return(false)
+ put :update, {:id => comment.to_param, :comment => {}}, valid_session
+ response.should render_template("edit")
+ end
+ end
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested comment" do
+ comment = Comment.create! valid_attributes
+ expect {
+ delete :destroy, {:id => comment.to_param}, valid_session
+ }.to change(Comment, :count).by(-1)
+ end
+
+ it "redirects to the comments list" do
+ comment = Comment.create! valid_attributes
+ delete :destroy, {:id => comment.to_param}, valid_session
+ response.should redirect_to(comments_url)
+ end
+ end
+
+end
View
164 spec/controllers/joins_controller_spec.rb
@@ -0,0 +1,164 @@
+require 'spec_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.
+
+describe JoinsController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # Join. As you add validations to Join, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # 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
+ # JoinsController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all joins as @joins" do
+ join = Join.create! valid_attributes
+ get :index, {}, valid_session
+ assigns(:joins).should eq([join])
+ end
+ end
+
+ describe "GET show" do
+ it "assigns the requested join as @join" do
+ join = Join.create! valid_attributes
+ get :show, {:id => join.to_param}, valid_session
+ assigns(:join).should eq(join)
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new join as @join" do
+ get :new, {}, valid_session
+ assigns(:join).should be_a_new(Join)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested join as @join" do
+ join = Join.create! valid_attributes
+ get :edit, {:id => join.to_param}, valid_session
+ assigns(:join).should eq(join)
+ end
+ end
+
+ describe "POST create" do
+ describe "with valid params" do
+ it "creates a new Join" do
+ expect {
+ post :create, {:join => valid_attributes}, valid_session
+ }.to change(Join, :count).by(1)
+ end
+
+ it "assigns a newly created join as @join" do
+ post :create, {:join => valid_attributes}, valid_session
+ assigns(:join).should be_a(Join)
+ assigns(:join).should be_persisted
+ end
+
+ it "redirects to the created join" do
+ post :create, {:join => valid_attributes}, valid_session
+ response.should redirect_to(Join.last)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns a newly created but unsaved join as @join" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Join.any_instance.stub(:save).and_return(false)
+ post :create, {:join => {}}, valid_session
+ assigns(:join).should be_a_new(Join)
+ end
+
+ it "re-renders the 'new' template" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Join.any_instance.stub(:save).and_return(false)
+ post :create, {:join => {}}, valid_session
+ response.should render_template("new")
+ end
+ end
+ end
+
+ describe "PUT update" do
+ describe "with valid params" do
+ it "updates the requested join" do
+ join = Join.create! valid_attributes
+ # Assuming there are no other joins in the database, this
+ # specifies that the Join created on the previous line
+ # receives the :update_attributes message with whatever params are
+ # submitted in the request.
+ Join.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, {:id => join.to_param, :join => {'these' => 'params'}}, valid_session
+ end
+
+ it "assigns the requested join as @join" do
+ join = Join.create! valid_attributes
+ put :update, {:id => join.to_param, :join => valid_attributes}, valid_session
+ assigns(:join).should eq(join)
+ end
+
+ it "redirects to the join" do
+ join = Join.create! valid_attributes
+ put :update, {:id => join.to_param, :join => valid_attributes}, valid_session
+ response.should redirect_to(join)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns the join as @join" do
+ join = Join.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Join.any_instance.stub(:save).and_return(false)
+ put :update, {:id => join.to_param, :join => {}}, valid_session
+ assigns(:join).should eq(join)
+ end
+
+ it "re-renders the 'edit' template" do
+ join = Join.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Join.any_instance.stub(:save).and_return(false)
+ put :update, {:id => join.to_param, :join => {}}, valid_session
+ response.should render_template("edit")
+ end
+ end
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested join" do
+ join = Join.create! valid_attributes
+ expect {
+ delete :destroy, {:id => join.to_param}, valid_session
+ }.to change(Join, :count).by(-1)
+ end
+
+ it "redirects to the joins list" do
+ join = Join.create! valid_attributes
+ delete :destroy, {:id => join.to_param}, valid_session
+ response.should redirect_to(joins_url)
+ end
+ end
+
+end
View
164 spec/controllers/parties_controller_spec.rb
@@ -0,0 +1,164 @@
+require 'spec_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.
+
+describe PartiesController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # Party. As you add validations to Party, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # 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
+ # PartiesController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all parties as @parties" do
+ party = Party.create! valid_attributes
+ get :index, {}, valid_session
+ assigns(:parties).should eq([party])
+ end
+ end
+
+ describe "GET show" do
+ it "assigns the requested party as @party" do
+ party = Party.create! valid_attributes
+ get :show, {:id => party.to_param}, valid_session
+ assigns(:party).should eq(party)
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new party as @party" do
+ get :new, {}, valid_session
+ assigns(:party).should be_a_new(Party)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested party as @party" do
+ party = Party.create! valid_attributes
+ get :edit, {:id => party.to_param}, valid_session
+ assigns(:party).should eq(party)
+ end
+ end
+
+ describe "POST create" do
+ describe "with valid params" do
+ it "creates a new Party" do
+ expect {
+ post :create, {:party => valid_attributes}, valid_session
+ }.to change(Party, :count).by(1)
+ end
+
+ it "assigns a newly created party as @party" do
+ post :create, {:party => valid_attributes}, valid_session
+ assigns(:party).should be_a(Party)
+ assigns(:party).should be_persisted
+ end
+
+ it "redirects to the created party" do
+ post :create, {:party => valid_attributes}, valid_session
+ response.should redirect_to(Party.last)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns a newly created but unsaved party as @party" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Party.any_instance.stub(:save).and_return(false)
+ post :create, {:party => {}}, valid_session
+ assigns(:party).should be_a_new(Party)
+ end
+
+ it "re-renders the 'new' template" do
+ # Trigger the behavior that occurs when invalid params are submitted
+ Party.any_instance.stub(:save).and_return(false)
+ post :create, {:party => {}}, valid_session
+ response.should render_template("new")
+ end
+ end
+ end
+
+ describe "PUT update" do
+ describe "with valid params" do
+ it "updates the requested party" do
+ party = Party.create! valid_attributes
+ # Assuming there are no other parties in the database, this
+ # specifies that the Party created on the previous line
+ # receives the :update_attributes message with whatever params are
+ # submitted in the request.
+ Party.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, {:id => party.to_param, :party => {'these' => 'params'}}, valid_session
+ end
+
+ it "assigns the requested party as @party" do
+ party = Party.create! valid_attributes
+ put :update, {:id => party.to_param, :party => valid_attributes}, valid_session
+ assigns(:party).should eq(party)
+ end
+
+ it "redirects to the party" do
+ party = Party.create! valid_attributes
+ put :update, {:id => party.to_param, :party => valid_attributes}, valid_session
+ response.should redirect_to(party)
+ end
+ end
+
+ describe "with invalid params" do
+ it "assigns the party as @party" do
+ party = Party.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Party.any_instance.stub(:save).and_return(false)
+ put :update, {:id => party.to_param, :party => {}}, valid_session
+ assigns(:party).should eq(party)
+ end
+
+ it "re-renders the 'edit' template" do
+ party = Party.create! valid_attributes
+ # Trigger the behavior that occurs when invalid params are submitted
+ Party.any_instance.stub(:save).and_return(false)
+ put :update, {:id => party.to_param, :party => {}}, valid_session
+ response.should render_template("edit")
+ end
+ end
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested party" do
+ party = Party.create! valid_attributes
+ expect {
+ delete :destroy, {:id => party.to_param}, valid_session
+ }.to change(Party, :count).by(-1)
+ end
+
+ it "redirects to the parties list" do
+ party = Party.create! valid_attributes
+ delete :destroy, {:id => party.to_param}, valid_session
+ response.should redirect_to(parties_url)
+ end
+ end
+
+end
View
167 spec/controllers/tasks_controller_spec.rb
@@ -0,0 +1,167 @@
+require 'spec_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.
+
+describe TasksController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # Task. As you add validations to Task, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # 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
+ # TasksController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ let!(:party) { Factory(:party) }
+ it "assigns all tasks as @tasks" do
+# task = Task.create! valid_attributes
+ task = Factory(:task)
+ get :index, {}, valid_session
+ response.should be_success
+# assigns(:tasks).should eq([task])
+ end
+ end
+
+ # describe "GET show" do
+ # it "assigns the requested task as @task" do
+ # task = Task.create! valid_attributes
+ # get :show, {:id => task.to_param}, valid_session
+ # assigns(:task).should eq(task)
+ # end
+ # end
+
+ # describe "GET new" do
+ # it "assigns a new task as @task" do
+ # get :new, {}, valid_session
+ # assigns(:task).should be_a_new(Task)
+ # end
+ # end
+
+ # describe "GET edit" do
+ # it "assigns the requested task as @task" do
+ # task = Task.create! valid_attributes
+ # get :edit, {:id => task.to_param}, valid_session
+ # assigns(:task).should eq(task)
+ # end
+ # end
+
+ # describe "POST create" do
+ # describe "with valid params" do
+ # it "creates a new Task" do
+ # expect {
+ # post :create, {:task => valid_attributes}, valid_session
+ # }.to change(Task, :count).by(1)
+ # end
+
+ # it "assigns a newly created task as @task" do
+ # post :create, {:task => valid_attributes}, valid_session
+ # assigns(:task).should be_a(Task)
+ # assigns(:task).should be_persisted
+ # end
+
+ # it "redirects to the created task" do
+ # post :create, {:task => valid_attributes}, valid_session
+ # response.should redirect_to(Task.last)
+ # end
+ # end
+
+ # describe "with invalid params" do
+ # it "assigns a newly created but unsaved task as @task" do
+ # # Trigger the behavior that occurs when invalid params are submitted
+ # Task.any_instance.stub(:save).and_return(false)
+ # post :create, {:task => {}}, valid_session
+ # assigns(:task).should be_a_new(Task)
+ # end
+
+ # it "re-renders the 'new' template" do
+ # # Trigger the behavior that occurs when invalid params are submitted
+ # Task.any_instance.stub(:save).and_return(false)
+ # post :create, {:task => {}}, valid_session
+ # response.should render_template("new")
+ # end
+ # end
+ # end
+
+ # describe "PUT update" do
+ # describe "with valid params" do
+ # it "updates the requested task" do
+ # task = Task.create! valid_attributes
+ # # Assuming there are no other tasks in the database, this
+ # # specifies that the Task created on the previous line
+ # # receives the :update_attributes message with whatever params are
+ # # submitted in the request.
+ # Task.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+ # put :update, {:id => task.to_param, :task => {'these' => 'params'}}, valid_session
+ # end
+
+ # it "assigns the requested task as @task" do
+ # task = Task.create! valid_attributes
+ # put :update, {:id => task.to_param, :task => valid_attributes}, valid_session
+ # assigns(:task).should eq(task)
+ # end
+
+ # it "redirects to the task" do
+ # task = Task.create! valid_attributes
+ # put :update, {:id => task.to_param, :task => valid_attributes}, valid_session
+ # response.should redirect_to(task)
+ # end
+ # end
+
+ # describe "with invalid params" do
+ # it "assigns the task as @task" do
+ # task = Task.create! valid_attributes
+ # # Trigger the behavior that occurs when invalid params are submitted
+ # Task.any_instance.stub(:save).and_return(false)
+ # put :update, {:id => task.to_param, :task => {}}, valid_session
+ # assigns(:task).should eq(task)
+ # end
+
+ # it "re-renders the 'edit' template" do
+ # task = Task.create! valid_attributes
+ # # Trigger the behavior that occurs when invalid params are submitted
+ # Task.any_instance.stub(:save).and_return(false)
+ # put :update, {:id => task.to_param, :task => {}}, valid_session
+ # response.should render_template("edit")
+ # end
+ # end
+ # end
+
+ # describe "DELETE destroy" do
+ # it "destroys the requested task" do
+ # task = Task.create! valid_attributes
+ # expect {
+ # delete :destroy, {:id => task.to_param}, valid_session
+ # }.to change(Task, :count).by(-1)
+ # end
+
+ # it "redirects to the tasks list" do
+ # task = Task.create! valid_attributes
+ # delete :destroy, {:id => task.to_param}, valid_session
+ # response.should redirect_to(tasks_url)
+ # end
+ # end
+
+end
View
27 spec/controllers/users_controller_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe UsersController do
+
+ # This should return the minimal set of attributes required to create a valid
+ # User. As you add validations to User, be sure to
+ # update the return value of this method accordingly.
+ def valid_attributes
+ {}
+ end
+
+ # 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
+ # UsersController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all users as @users" do
+ user = User.create! valid_attributes
+ get :index, {}, valid_session
+ assigns(:users).should eq([user])
+ end
+ end
+
+end
View
9 spec/factories/comments.rb
@@ -0,0 +1,9 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :comment do
+ task_id 1
+ user_id 1
+ content "My Comment"
+ end
+end
View
13 spec/factories/joins.rb
@@ -0,0 +1,13 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :join do
+ user_id 1
+ party_id 1
+ state "chore"
+ started_at "2012-06-30 15:00:09"
+ finished_at "2012-06-30 15:00:09"
+ end_hour 1
+ end_min 1
+ end
+end
View
9 spec/factories/parties.rb
@@ -0,0 +1,9 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :party do
+ name "My Party"
+ description "My Hackason"
+ user_id 1
+ end
+end
View
12 spec/factories/tasks.rb
@@ -0,0 +1,12 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :task do
+ user_id 1
+ party_id 1
+ content "My Task"
+ state "backlog"
+ help false
+ finished_at "2012-06-30 15:01:11"
+ end
+end
View
10 spec/factories/users.rb
@@ -0,0 +1,10 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :user do
+ name "user1"
+ image "user1.png"
+ email "user1@example.com"
+ password "testpass"
+ end
+end
View
10 spec/models/comment_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Comment do
+
+ describe "associations" do
+ it { should belong_to(:task) }
+ it { should belong_to(:user) }
+ end
+
+end
View
17 spec/models/join_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe Join do
+
+ describe "associations" do
+ it { should belong_to(:party) }
+ it { should belong_to(:user) }
+ end
+