From a7f37fb31c7a5df5c957fe6d9d1bda3322db19c6 Mon Sep 17 00:00:00 2001 From: nilsding Date: Tue, 11 Nov 2014 07:10:41 +0100 Subject: [PATCH] added Inbox controller --- app/assets/javascripts/inbox.coffee | 3 +++ app/assets/stylesheets/inbox.css.scss | 3 +++ app/controllers/inbox_controller.rb | 5 +++++ app/helpers/inbox_helper.rb | 2 ++ app/views/inbox/show.html.haml | 7 +++++++ config/routes.rb | 2 ++ test/controllers/inbox_controller_test.rb | 9 +++++++++ test/helpers/inbox_helper_test.rb | 4 ++++ 8 files changed, 35 insertions(+) create mode 100644 app/assets/javascripts/inbox.coffee create mode 100644 app/assets/stylesheets/inbox.css.scss create mode 100644 app/controllers/inbox_controller.rb create mode 100644 app/helpers/inbox_helper.rb create mode 100644 app/views/inbox/show.html.haml create mode 100644 test/controllers/inbox_controller_test.rb create mode 100644 test/helpers/inbox_helper_test.rb diff --git a/app/assets/javascripts/inbox.coffee b/app/assets/javascripts/inbox.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/inbox.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/inbox.css.scss b/app/assets/stylesheets/inbox.css.scss new file mode 100644 index 00000000..07a9c997 --- /dev/null +++ b/app/assets/stylesheets/inbox.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the inbox 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/inbox_controller.rb b/app/controllers/inbox_controller.rb new file mode 100644 index 00000000..47353289 --- /dev/null +++ b/app/controllers/inbox_controller.rb @@ -0,0 +1,5 @@ +class InboxController < ApplicationController + def show + @inbox = Inbox.where(user: current_user).order(:created_at).reverse_order + end +end diff --git a/app/helpers/inbox_helper.rb b/app/helpers/inbox_helper.rb new file mode 100644 index 00000000..4c6ced5c --- /dev/null +++ b/app/helpers/inbox_helper.rb @@ -0,0 +1,2 @@ +module InboxHelper +end diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml new file mode 100644 index 00000000..c9e717d7 --- /dev/null +++ b/app/views/inbox/show.html.haml @@ -0,0 +1,7 @@ +%ul + - @inbox.each do |i| + %li + %strong + = user_screen_name i.question.user + asked + = i.question.content diff --git a/config/routes.rb b/config/routes.rb index e05f2acf..fa8b9a98 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,8 @@ Rails.application.routes.draw do match '/ask', to: 'question#create', via: :post, as: :ask end + match '/inbox', to: 'inbox#show', via: 'get' + match '/user/:username', to: 'user#show', via: 'get' match '/@:username', to: 'user#show', via: 'get', as: :show_user_profile match '/:username', to: 'user#show', via: 'get', as: :show_user_profile_alt diff --git a/test/controllers/inbox_controller_test.rb b/test/controllers/inbox_controller_test.rb new file mode 100644 index 00000000..ef31f0d4 --- /dev/null +++ b/test/controllers/inbox_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class InboxControllerTest < ActionController::TestCase + test "should get show" do + get :show + assert_response :success + end + +end diff --git a/test/helpers/inbox_helper_test.rb b/test/helpers/inbox_helper_test.rb new file mode 100644 index 00000000..6f6f0bb7 --- /dev/null +++ b/test/helpers/inbox_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class InboxHelperTest < ActionView::TestCase +end