diff --git a/app/controllers/desktop/journal_lists_controller.rb b/app/controllers/desktop/journal_lists_controller.rb new file mode 100644 index 000000000..f4a0d980e --- /dev/null +++ b/app/controllers/desktop/journal_lists_controller.rb @@ -0,0 +1,83 @@ +class Desktop::JournalListsController < ApplicationController + # GET /desktop/journal_lists + # GET /desktop/journal_lists.json + def index + @desktop_journal_lists = Desktop::JournalList.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @desktop_journal_lists } + end + end + + # GET /desktop/journal_lists/1 + # GET /desktop/journal_lists/1.json + def show + @desktop_journal_list = Desktop::JournalList.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @desktop_journal_list } + end + end + + # GET /desktop/journal_lists/new + # GET /desktop/journal_lists/new.json + def new + @desktop_journal_list = Desktop::JournalList.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @desktop_journal_list } + end + end + + # GET /desktop/journal_lists/1/edit + def edit + @desktop_journal_list = Desktop::JournalList.find(params[:id]) + end + + # POST /desktop/journal_lists + # POST /desktop/journal_lists.json + def create + @desktop_journal_list = Desktop::JournalList.new(params[:desktop_journal_list]) + + respond_to do |format| + if @desktop_journal_list.save + format.html { redirect_to @desktop_journal_list, notice: 'Journal list was successfully created.' } + format.json { render json: @desktop_journal_list, status: :created, location: @desktop_journal_list } + else + format.html { render action: "new" } + format.json { render json: @desktop_journal_list.errors, status: :unprocessable_entity } + end + end + end + + # PUT /desktop/journal_lists/1 + # PUT /desktop/journal_lists/1.json + def update + @desktop_journal_list = Desktop::JournalList.find(params[:id]) + + respond_to do |format| + if @desktop_journal_list.update_attributes(params[:desktop_journal_list]) + format.html { redirect_to @desktop_journal_list, notice: 'Journal list was successfully updated.' } + format.json { head :ok } + else + format.html { render action: "edit" } + format.json { render json: @desktop_journal_list.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /desktop/journal_lists/1 + # DELETE /desktop/journal_lists/1.json + def destroy + @desktop_journal_list = Desktop::JournalList.find(params[:id]) + @desktop_journal_list.destroy + + respond_to do |format| + format.html { redirect_to desktop_journal_lists_url } + format.json { head :ok } + end + end +end diff --git a/app/helpers/desktop/journal_lists_helper.rb b/app/helpers/desktop/journal_lists_helper.rb new file mode 100644 index 000000000..e21dc09f3 --- /dev/null +++ b/app/helpers/desktop/journal_lists_helper.rb @@ -0,0 +1,2 @@ +module Desktop::JournalListsHelper +end diff --git a/app/views/desktop/journal_lists/_form.html.erb b/app/views/desktop/journal_lists/_form.html.erb new file mode 100644 index 000000000..ac7f7ac68 --- /dev/null +++ b/app/views/desktop/journal_lists/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(@desktop_journal_list) do |f| %> + <% if @desktop_journal_list.errors.any? %> +
+ | + | + |
---|---|---|
<%= link_to 'Show', desktop_journal_list %> | +<%= link_to 'Edit', edit_desktop_journal_list_path(desktop_journal_list) %> | +<%= link_to 'Destroy', desktop_journal_list, confirm: 'Are you sure?', method: :delete %> | +
<%= notice %>
+ + +<%= link_to 'Edit', edit_desktop_journal_list_path(@desktop_journal_list) %> | +<%= link_to 'Back', desktop_journal_lists_path %> diff --git a/spec/controllers/desktop/journal_lists_controller_spec.rb b/spec/controllers/desktop/journal_lists_controller_spec.rb new file mode 100644 index 000000000..99d2e2dc0 --- /dev/null +++ b/spec/controllers/desktop/journal_lists_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 Desktop::JournalListsController do + + # This should return the minimal set of attributes required to create a valid + # Desktop::JournalList. As you add validations to Desktop::JournalList, 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 + # Desktop::JournalListsController. Be sure to keep this updated too. + def valid_session + {} + end + + describe "GET index" do + it "assigns all desktop_journal_lists as @desktop_journal_lists" do + journal_list = Desktop::JournalList.create! valid_attributes + get :index, {}, valid_session + assigns(:desktop_journal_lists).should eq([journal_list]) + end + end + + describe "GET show" do + it "assigns the requested desktop_journal_list as @desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + get :show, {:id => journal_list.to_param}, valid_session + assigns(:desktop_journal_list).should eq(journal_list) + end + end + + describe "GET new" do + it "assigns a new desktop_journal_list as @desktop_journal_list" do + get :new, {}, valid_session + assigns(:desktop_journal_list).should be_a_new(Desktop::JournalList) + end + end + + describe "GET edit" do + it "assigns the requested desktop_journal_list as @desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + get :edit, {:id => journal_list.to_param}, valid_session + assigns(:desktop_journal_list).should eq(journal_list) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Desktop::JournalList" do + expect { + post :create, {:desktop_journal_list => valid_attributes}, valid_session + }.to change(Desktop::JournalList, :count).by(1) + end + + it "assigns a newly created desktop_journal_list as @desktop_journal_list" do + post :create, {:desktop_journal_list => valid_attributes}, valid_session + assigns(:desktop_journal_list).should be_a(Desktop::JournalList) + assigns(:desktop_journal_list).should be_persisted + end + + it "redirects to the created desktop_journal_list" do + post :create, {:desktop_journal_list => valid_attributes}, valid_session + response.should redirect_to(Desktop::JournalList.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved desktop_journal_list as @desktop_journal_list" do + # Trigger the behavior that occurs when invalid params are submitted + Desktop::JournalList.any_instance.stub(:save).and_return(false) + post :create, {:desktop_journal_list => {}}, valid_session + assigns(:desktop_journal_list).should be_a_new(Desktop::JournalList) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Desktop::JournalList.any_instance.stub(:save).and_return(false) + post :create, {:desktop_journal_list => {}}, valid_session + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + # Assuming there are no other desktop_journal_lists in the database, this + # specifies that the Desktop::JournalList created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Desktop::JournalList.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, {:id => journal_list.to_param, :desktop_journal_list => {'these' => 'params'}}, valid_session + end + + it "assigns the requested desktop_journal_list as @desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + put :update, {:id => journal_list.to_param, :desktop_journal_list => valid_attributes}, valid_session + assigns(:desktop_journal_list).should eq(journal_list) + end + + it "redirects to the desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + put :update, {:id => journal_list.to_param, :desktop_journal_list => valid_attributes}, valid_session + response.should redirect_to(journal_list) + end + end + + describe "with invalid params" do + it "assigns the desktop_journal_list as @desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Desktop::JournalList.any_instance.stub(:save).and_return(false) + put :update, {:id => journal_list.to_param, :desktop_journal_list => {}}, valid_session + assigns(:desktop_journal_list).should eq(journal_list) + end + + it "re-renders the 'edit' template" do + journal_list = Desktop::JournalList.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Desktop::JournalList.any_instance.stub(:save).and_return(false) + put :update, {:id => journal_list.to_param, :desktop_journal_list => {}}, valid_session + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested desktop_journal_list" do + journal_list = Desktop::JournalList.create! valid_attributes + expect { + delete :destroy, {:id => journal_list.to_param}, valid_session + }.to change(Desktop::JournalList, :count).by(-1) + end + + it "redirects to the desktop_journal_lists list" do + journal_list = Desktop::JournalList.create! valid_attributes + delete :destroy, {:id => journal_list.to_param}, valid_session + response.should redirect_to(desktop_journal_lists_url) + end + end + +end diff --git a/spec/helpers/desktop/journal_lists_helper_spec.rb b/spec/helpers/desktop/journal_lists_helper_spec.rb new file mode 100644 index 000000000..47b911a92 --- /dev/null +++ b/spec/helpers/desktop/journal_lists_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the Desktop::JournalListsHelper. For example: +# +# describe Desktop::JournalListsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe Desktop::JournalListsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/desktop/desktop_journal_lists_spec.rb b/spec/requests/desktop/desktop_journal_lists_spec.rb new file mode 100644 index 000000000..c1ac52e3f --- /dev/null +++ b/spec/requests/desktop/desktop_journal_lists_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe "Desktop::JournalLists" do + describe "GET /desktop_journal_lists" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + get desktop_journal_lists_path + response.status.should be(200) + end + end +end diff --git a/spec/routing/desktop/journal_lists_routing_spec.rb b/spec/routing/desktop/journal_lists_routing_spec.rb new file mode 100644 index 000000000..79eac59e9 --- /dev/null +++ b/spec/routing/desktop/journal_lists_routing_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe Desktop::JournalListsController do + describe "routing" do + + it "routes to #index" do + get("/desktop/journal_lists").should route_to("desktop/journal_lists#index") + end + + it "routes to #new" do + get("/desktop/journal_lists/new").should route_to("desktop/journal_lists#new") + end + + it "routes to #show" do + get("/desktop/journal_lists/1").should route_to("desktop/journal_lists#show", :id => "1") + end + + it "routes to #edit" do + get("/desktop/journal_lists/1/edit").should route_to("desktop/journal_lists#edit", :id => "1") + end + + it "routes to #create" do + post("/desktop/journal_lists").should route_to("desktop/journal_lists#create") + end + + it "routes to #update" do + put("/desktop/journal_lists/1").should route_to("desktop/journal_lists#update", :id => "1") + end + + it "routes to #destroy" do + delete("/desktop/journal_lists/1").should route_to("desktop/journal_lists#destroy", :id => "1") + end + + end +end diff --git a/spec/views/desktop/journal_lists/edit.html.erb_spec.rb b/spec/views/desktop/journal_lists/edit.html.erb_spec.rb new file mode 100644 index 000000000..92a7ab733 --- /dev/null +++ b/spec/views/desktop/journal_lists/edit.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "desktop/journal_lists/edit" do + before(:each) do + @desktop_journal_list = assign(:desktop_journal_list, stub_model(Desktop::JournalList)) + end + + it "renders the edit desktop_journal_list form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => desktop_journal_lists_path(@desktop_journal_list), :method => "post" do + end + end +end diff --git a/spec/views/desktop/journal_lists/index.html.erb_spec.rb b/spec/views/desktop/journal_lists/index.html.erb_spec.rb new file mode 100644 index 000000000..93bfc83bf --- /dev/null +++ b/spec/views/desktop/journal_lists/index.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "desktop/journal_lists/index" do + before(:each) do + assign(:desktop_journal_lists, [ + stub_model(Desktop::JournalList), + stub_model(Desktop::JournalList) + ]) + end + + it "renders a list of desktop/journal_lists" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/spec/views/desktop/journal_lists/new.html.erb_spec.rb b/spec/views/desktop/journal_lists/new.html.erb_spec.rb new file mode 100644 index 000000000..b9751d445 --- /dev/null +++ b/spec/views/desktop/journal_lists/new.html.erb_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "desktop/journal_lists/new" do + before(:each) do + assign(:desktop_journal_list, stub_model(Desktop::JournalList).as_new_record) + end + + it "renders new desktop_journal_list form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => desktop_journal_lists_path, :method => "post" do + end + end +end diff --git a/spec/views/desktop/journal_lists/show.html.erb_spec.rb b/spec/views/desktop/journal_lists/show.html.erb_spec.rb new file mode 100644 index 000000000..d18b4ece2 --- /dev/null +++ b/spec/views/desktop/journal_lists/show.html.erb_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "desktop/journal_lists/show" do + before(:each) do + @desktop_journal_list = assign(:desktop_journal_list, stub_model(Desktop::JournalList)) + end + + it "renders attributes in" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end