From 836ed7aa85ddec1e3ea9877ca3b2accea8a1f212 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 21 Aug 2013 17:52:10 +1000 Subject: [PATCH] Added creator to scientific name views etc --- app/controllers/scientific_names_controller.rb | 1 + app/views/scientific_names/edit.html.haml | 6 ++++++ spec/views/scientific_names/edit.html.haml_spec.rb | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/app/controllers/scientific_names_controller.rb b/app/controllers/scientific_names_controller.rb index cb65fc999..202c3942c 100644 --- a/app/controllers/scientific_names_controller.rb +++ b/app/controllers/scientific_names_controller.rb @@ -45,6 +45,7 @@ class ScientificNamesController < ApplicationController # POST /scientific_names # POST /scientific_names.json def create + params[:scientific_name][:creator_id] = current_member.id @scientific_name = ScientificName.new(params[:scientific_name]) respond_to do |format| diff --git a/app/views/scientific_names/edit.html.haml b/app/views/scientific_names/edit.html.haml index 493ee3e44..db7f9bf71 100644 --- a/app/views/scientific_names/edit.html.haml +++ b/app/views/scientific_names/edit.html.haml @@ -1,3 +1,9 @@ - content_for :title, "Edit scientific name" +%p + Added by + = @scientific_name.creator + = distance_of_time_in_words(@scientific_name.created_at, Time.zone.now) + ago. + = render 'form' diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 30e195f52..1b48c51cd 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -12,6 +12,10 @@ describe "scientific_names/edit" do render end + it "shows the creator" do + rendered.should contain "Added by #{@scientific_name.creator} less than a minute ago." + end + it "renders the edit scientific_name form" do assert_select "form", :action => scientific_names_path(@scientific_name), :method => "post" do assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]"