224 | <% end %>
225 |
226 | === Don't display URL shortening
227 |
228 | The index page shows all the links, including links like http://bit.ly and the the real one.
229 | To only return the real URLs we can use rules, which is a bit similar to scope in ActiveRecord.
230 |
231 | ==== app/models/links.rb
232 |
233 | rule(:real) { redirected_link.nil?}
234 |
235 | This means that it will group all links under the rule :real which does not have a redirected_link
236 | To return all those nodes, use the class method #real. Notice you can do some really interesting queries using rules and cypher together, see "Rules-Cypher":https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3AWrapper-Rules-and-Functions
237 |
238 | Btw, the Neo4j::Rails::Model#all method is also implemented as a rule.
239 | You can also chain rules, just like scopes in Active Record.
240 |
241 | ==== app/controllers/links_controller.rb
242 |
243 | def index
244 | @links = Link.real
245 |
246 | respond_to do |format|
247 | format.html # index.html.erb
248 | format.json { render :json => @links }
249 | end
250 | end
251 |
252 | Since the rules do work by creating relationships when new nodes are created/updated/deleted we must do another
253 | search or stop the rails server and delete the database 'db/neo4j-developement'
254 |
255 | === Pagination
256 |
257 | The list of all tweets (http://localhost:3000/tweets ) does not look good. It needs some pagination.
258 | Add the two gem in Gemfile:
259 |
260 | gem 'neo4j-will_paginate', :git => 'git://github.com/andreasronge/neo4j-will_paginate.git'
261 | gem 'will_paginate'
262 |
263 | ==== app/controllers/tweet_controller.rb
264 |
265 | Neo4j.rb comes included with the will_paginate gem.
266 | Change the index method
267 |
268 | @tweets = Tweet.all
269 | to
270 | @tweets = Tweet.all.paginate(:page => params[:page], :per_page => 10)
271 |
272 | Pagination is support for all traversals and lucene queries.
273 |
274 | ==== app/views/tweets/index.html.erb
275 |
276 | Add the following line before the table:
277 |
278 | <%= will_paginate(@tweets) %>
279 |
280 | === Searching and Sorting
281 |
282 | Lets say we want to sort the tweets by the text. Lucene has two types of indexes: exact and fulltext.
283 | The exact index is perfect for keywords while the fulltext is for longer texts.
284 | We have already changed the index of text to fulltext for the app/models/tweets.rb
285 | See http://lucene.apache.org/java/3_0_0/queryparsersyntax.html for the query syntax.
286 |
287 | ==== app/views/tweets/index.html.erb
288 |
289 | Add the following form before the table
290 |
291 | <%= form_for(:tweets, :method => :get) do |f| %>
292 |
568 |
569 | ==== app/controller/
570 |
571 | Add the following line in the show method after the Tag.find line
572 |
573 | @tweets = @tag.tweets.paginate(:page => params[:page], :per_page => 10)
574 |
575 | === Recommendations
576 |
577 | ==== app/controllers/user_controllers.rb
578 |
579 | The following algorithm works like this:
580 |
581 | 1. Get all the users who are also using my tags.
582 | 2. For each of those users get their used tags and compare with mine.
583 | 3. Select the user who has the most similar tags to mine.
584 |
585 | Add the following at the bottom of the file user_controllers.rb
586 |
587 | private
588 |
589 | def recommend(user)
590 | my_tags = user.used_tags.to_a
591 | my_friends = user.knows.to_a
592 |
593 | # we are here using the raw java API - that's why using _java_node, raw and wrapper
594 | other_users = user._java_node.outgoing(:used_tags).incoming(:used_tags).raw.depth(2).filter{|path| path.length == 2 && !my_friends.include?(path.end_node)}
595 |
596 | # for all those users, find the person who has the max number of same tags as I have
597 | found = other_users.max_by{|friend| (friend.outgoing(:used_tags).raw.map{|tag| tag[:name]} & my_tags).size }
598 |
599 | found && found.wrapper # load the ruby wrapper around the neo4j java node
600 | end
601 |
602 | ==== app/controllers/user_controllers.rb
603 |
604 | Add one line to the show method:
605 |
606 | def show
607 | @user = User.find(params[:id])
608 | @recommend = recommend(@user)
609 |
610 | respond_to do |format|
611 | format.html # show.html.erb
612 | format.json { render :json => @user }
613 | end
614 | end
615 |
616 |
617 | ==== app/views/users/show.html.erb
618 |
619 | Display a recommendation if available
620 |
621 | <% if @recommend %>
622 |
49 |
50 |
51 |
52 | <%= link_to 'Edit', edit_user_path(@user) %> |
53 | <%= link_to 'Back', users_path %>
54 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Kvitter::Application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # -*- coding: undecided -*-
3 | require File.expand_path('../boot', __FILE__)
4 |
5 | require "action_controller/railtie"
6 | require "action_mailer/railtie"
7 | require "active_resource/railtie"
8 | require "rails/test_unit/railtie"
9 | require 'sprockets/railtie'
10 | require 'neo4j'
11 |
12 |
13 | if defined?(Bundler)
14 | # If you precompile assets before deploying to production, use this line
15 | Bundler.require(*Rails.groups(:assets => %w(development test)))
16 | # If you want your assets lazily compiled in production, use this line
17 | # Bundler.require(:default, :assets, Rails.env)
18 | end
19 |
20 | module Kvitter
21 | class Application < Rails::Application
22 | # Settings in config/environments/* take precedence over those specified here.
23 | # Application configuration should go into files in config/initializers
24 | # -- all .rb files in that directory are automatically loaded.
25 |
26 | # Custom directories with classes and modules you want to be autoloadable.
27 | # config.autoload_paths += %W(#{config.root}/extras)
28 |
29 | # Only load the plugins named here, in the order given (default is alphabetical).
30 | # :all can be used as a placeholder for all plugins not explicitly named.
31 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
32 |
33 | # Activate observers that should always be running.
34 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
35 |
36 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
37 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
38 | # config.time_zone = 'Central Time (US & Canada)'
39 |
40 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
41 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
42 | # config.i18n.default_locale = :de
43 |
44 | # Configure the default encoding used in templates for Ruby 1.9.
45 | config.encoding = "utf-8"
46 |
47 | # Configure sensitive parameters which will be filtered from the log file.
48 | config.filter_parameters += [:password]
49 |
50 | # Enable Neo4j generators, e.g: rails generate model Admin --parent User
51 | config.generators do |g|
52 | g.orm :neo4j
53 | g.test_framework :rspec, :fixture => false
54 | end
55 |
56 | # Configure where the neo4j database should exist
57 | config.neo4j.storage_path = "#{config.root}/db/neo4j-#{Rails.env}"
58 |
59 | config.neo4j.identity_map = false
60 |
61 | # Enable the asset pipeline
62 | config.assets.enabled = true
63 |
64 | # Version of your assets, change this if you want to expire all your assets
65 | config.assets.version = '1.0'
66 | end
67 | end
68 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'rubygems'
3 |
4 | # Set up gems listed in the Gemfile.
5 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
6 |
7 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
8 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem 'activerecord-jdbcsqlite3-adapter'
3 | #
4 | # Configure Using Gemfile
5 | # gem 'activerecord-jdbcsqlite3-adapter'
6 | #
7 | development:
8 | adapter: sqlite3
9 | database: db/development.sqlite3
10 |
11 | # Warning: The database defined as "test" will be erased and
12 | # re-generated from your development database when you run "rake".
13 | # Do not set this db to the same as development or production.
14 | test:
15 | adapter: sqlite3
16 | database: db/test.sqlite3
17 |
18 | production:
19 | adapter: sqlite3
20 | database: db/production.sqlite3
21 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Load the rails application
3 | require File.expand_path('../application', __FILE__)
4 |
5 | # Initialize the rails application
6 | Kvitter::Application.initialize!
7 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | Kvitter::Application.configure do
3 | # Settings specified here will take precedence over those in config/application.rb
4 |
5 | # In the development environment your application's code is reloaded on
6 | # every request. This slows down response time but is perfect for development
7 | # since you don't have to restart the web server when you make code changes.
8 | config.cache_classes = false
9 |
10 | # Log error messages when you accidentally call methods on nil.
11 | config.whiny_nils = true
12 |
13 | # Show full error reports and disable caching
14 | config.consider_all_requests_local = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Don't care if the mailer can't send
18 | config.action_mailer.raise_delivery_errors = false
19 |
20 | # Print deprecation notices to the Rails logger
21 | config.active_support.deprecation = :log
22 |
23 | # Only use best-standards-support built into browsers
24 | config.action_dispatch.best_standards_support = :builtin
25 |
26 | # Do not compress assets
27 | config.assets.compress = false
28 |
29 | # Expands the lines which load the assets
30 | config.assets.debug = true
31 | end
32 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | Kvitter::Application.configure do
3 | # Settings specified here will take precedence over those in config/application.rb
4 |
5 | # Code is not reloaded between requests
6 | config.cache_classes = true
7 |
8 | # Full error reports are disabled and caching is turned on
9 | config.consider_all_requests_local = false
10 | config.action_controller.perform_caching = true
11 |
12 | # Disable Rails's static asset server (Apache or nginx will already do this)
13 | config.serve_static_assets = true
14 |
15 | # Compress JavaScripts and CSS
16 | config.assets.compress = true
17 |
18 | # Don't fallback to assets pipeline if a precompiled asset is missed
19 | config.assets.compile = false
20 |
21 | # Generate digests for assets URLs
22 | config.assets.digest = true
23 |
24 | # Defaults to Rails.root.join("public/assets")
25 | # config.assets.manifest = YOUR_PATH
26 |
27 | # Specifies the header that your server uses for sending files
28 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
29 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
30 |
31 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
32 | # config.force_ssl = true
33 |
34 | # See everything in the log (default is :info)
35 | # config.log_level = :debug
36 |
37 | # Use a different logger for distributed setups
38 | # config.logger = SyslogLogger.new
39 |
40 | # Use a different cache store in production
41 | # config.cache_store = :mem_cache_store
42 |
43 | # Enable serving of images, stylesheets, and JavaScripts from an asset server
44 | # config.action_controller.asset_host = "http://assets.example.com"
45 |
46 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
47 | # config.assets.precompile += %w( search.js )
48 |
49 | # Disable delivery errors, bad email addresses will be ignored
50 | # config.action_mailer.raise_delivery_errors = false
51 |
52 | # Enable threaded mode
53 | config.threadsafe!
54 |
55 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
56 | # the I18n.default_locale when a translation can not be found)
57 | config.i18n.fallbacks = true
58 |
59 | # Send deprecation notices to registered listeners
60 | config.active_support.deprecation = :notify
61 | end
62 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | Kvitter::Application.configure do
3 | # Settings specified here will take precedence over those in config/application.rb
4 |
5 | # The test environment is used exclusively to run your application's
6 | # test suite. You never need to work with it otherwise. Remember that
7 | # your test database is "scratch space" for the test suite and is wiped
8 | # and recreated between test runs. Don't rely on the data there!
9 | config.cache_classes = true
10 |
11 | # Configure static asset server for tests with Cache-Control for performance
12 | config.serve_static_assets = true
13 | config.static_cache_control = "public, max-age=3600"
14 |
15 | # Log error messages when you accidentally call methods on nil
16 | config.whiny_nils = true
17 |
18 | # Show full error reports and disable caching
19 | config.consider_all_requests_local = true
20 | config.action_controller.perform_caching = false
21 |
22 | # Raise exceptions instead of rendering exception templates
23 | config.action_dispatch.show_exceptions = false
24 |
25 | # Disable request forgery protection in test environment
26 | config.action_controller.allow_forgery_protection = false
27 |
28 | # Tell Action Mailer not to deliver emails to the real world.
29 | # The :test delivery method accumulates sent emails in the
30 | # ActionMailer::Base.deliveries array.
31 | config.action_mailer.delivery_method = :test
32 |
33 | # Use SQL instead of Active Record's schema dumper when creating the test database.
34 | # This is necessary if your schema can't be completely dumped by the schema dumper,
35 | # like if you have constraints or database-specific column types
36 | # config.active_record.schema_format = :sql
37 |
38 | # Print deprecation notices to the stderr
39 | config.active_support.deprecation = :stderr
40 | end
41 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6 |
7 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8 | # Rails.backtrace_cleaner.remove_silencers!
9 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new inflection rules using the following format
5 | # (all these examples are active by default):
6 | # ActiveSupport::Inflector.inflections do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Add new mime types for use in respond_to blocks:
5 | # Mime::Type.register "text/richtext", :rtf
6 | # Mime::Type.register_alias "text/html", :iphone
7 |
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 |
4 | # Your secret key for verifying the integrity of signed cookies.
5 | # If you change this key, all old signed cookies will become invalid!
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | Kvitter::Application.config.secret_token = '025c6ea650ad4a77606eb82ca9bcd5decdfb5277ed6d7bbb78406232376a8b183fd6a05d9501754df9aceee58bdc6420f52023b59576e850ed7787b3d3d86b70'
9 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 |
4 | Kvitter::Application.config.session_store :cookie_store, :key => '_kvitter_session'
5 |
6 | # Use the database for sessions instead of the cookie-based default,
7 | # which shouldn't be used to store highly confidential information
8 | # (create the session table with "rails generate session_migration")
9 | # Kvitter::Application.config.session_store :active_record_store
10 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # Be sure to restart your server when you modify this file.
3 | #
4 | # This file contains settings for ActionController::ParamsWrapper which
5 | # is enabled by default.
6 |
7 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
8 | ActiveSupport.on_load(:action_controller) do
9 | wrap_parameters :format => [:json]
10 | end
11 |
12 | # Disable root element in JSON by default.
13 | ActiveSupport.on_load(:active_record) do
14 | self.include_root_in_json = false
15 | end
16 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | Kvitter::Application.routes.draw do
3 |
4 | resources :tweets
5 |
6 | resources :tags do
7 | get :search, :on => :member
8 | end
9 |
10 | resources :links
11 |
12 | resources :users
13 |
14 | root :to => 'tags#index'
15 |
16 | # The priority is based upon order of creation:
17 | # first created -> highest priority.
18 |
19 | # Sample of regular route:
20 | # match 'products/:id' => 'catalog#view'
21 | # Keep in mind you can assign values other than :controller and :action
22 |
23 | # Sample of named route:
24 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
25 | # This route can be invoked with purchase_url(:id => product.id)
26 |
27 | # Sample resource route (maps HTTP verbs to controller actions automatically):
28 | # resources :products
29 |
30 | # Sample resource route with options:
31 | # resources :products do
32 | # member do
33 | # get 'short'
34 | # post 'toggle'
35 | # end
36 | #
37 | # collection do
38 | # get 'sold'
39 | # end
40 | # end
41 |
42 | # Sample resource route with sub-resources:
43 | # resources :products do
44 | # resources :comments, :sales
45 | # resource :seller
46 | # end
47 |
48 | # Sample resource route with more complex sub-resources
49 | # resources :products do
50 | # resources :comments
51 | # resources :sales do
52 | # get 'recent', :on => :collection
53 | # end
54 | # end
55 |
56 | # Sample resource route within a namespace:
57 | # namespace :admin do
58 | # # Directs /admin/products/* to Admin::ProductsController
59 | # # (app/controllers/admin/products_controller.rb)
60 | # resources :products
61 | # end
62 |
63 | # You can have the root of your site routed with "root"
64 | # just remember to delete public/index.html.
65 | # root :to => 'welcome#index'
66 |
67 | # See how all your routes lay out with "rake routes"
68 |
69 | # This is a legacy wild controller route that's not recommended for RESTful applications.
70 | # Note: This route will make all actions in every controller accessible via GET requests.
71 | # match ':controller(/:action(/:id(.:format)))'
72 | end
73 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | # This file should contain all the record creation needed to seed the database with its default values.
3 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
4 | #
5 | # Examples:
6 | #
7 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
8 | # Mayor.create(:name => 'Emanuel', :city => cities.first)
9 |
--------------------------------------------------------------------------------
/doc/README_FOR_APP:
--------------------------------------------------------------------------------
1 | Use this README file to introduce your application and point to useful places in the API for learning more.
2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
3 |
--------------------------------------------------------------------------------
/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/lib/assets/.gitkeep
--------------------------------------------------------------------------------
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/lib/tasks/.gitkeep
--------------------------------------------------------------------------------
/log/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/log/.gitkeep
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.
We've been notified about this issue and we'll take a look at it shortly.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/public/favicon.ico
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env jruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/spec/controllers/links_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # This spec was generated by rspec-rails when you ran the scaffold generator.
5 | # It demonstrates how one might use RSpec to specify the controller code that
6 | # was generated by Rails when you ran the scaffold generator.
7 | #
8 | # It assumes that the implementation code is generated by the rails scaffold
9 | # generator. If you are using any extension libraries to generate different
10 | # controller code, this generated spec may or may not pass.
11 | #
12 | # It only uses APIs available in rails and/or rspec-rails. There are a number
13 | # of tools you can use to make these specs even more expressive, but we're
14 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
15 | #
16 | # Compared to earlier versions of this generator, there is very limited use of
17 | # stubs and message expectations in this spec. Stubs are only used when there
18 | # is no simpler way to get a handle on the object needed for the example.
19 | # Message expectations are only used when there is no simpler way to specify
20 | # that an instance is receiving a specific message.
21 |
22 | describe LinksController do
23 |
24 | # This should return the minimal set of attributes required to create a valid
25 | # Link. As you add validations to Link, be sure to
26 | # update the return value of this method accordingly.
27 | def valid_attributes
28 | {}
29 | end
30 |
31 | describe "GET index" do
32 | it "assigns all links as @links" do
33 | link = Link.create! valid_attributes
34 | get :index
35 | assigns(:links).should eq([link])
36 | end
37 | end
38 |
39 | describe "GET show" do
40 | it "assigns the requested link as @link" do
41 | link = Link.create! valid_attributes
42 | get :show, :id => link.id
43 | assigns(:link).should eq(link)
44 | end
45 | end
46 |
47 | describe "GET new" do
48 | it "assigns a new link as @link" do
49 | get :new
50 | assigns(:link).should be_a_new(Link)
51 | end
52 | end
53 |
54 | describe "GET edit" do
55 | it "assigns the requested link as @link" do
56 | link = Link.create! valid_attributes
57 | get :edit, :id => link.id
58 | assigns(:link).should eq(link)
59 | end
60 | end
61 |
62 | describe "POST create" do
63 | describe "with valid params" do
64 | it "creates a new Link" do
65 | expect {
66 | post :create, :link => valid_attributes
67 | }.to change(Link, :count).by(1)
68 | end
69 |
70 | it "assigns a newly created link as @link" do
71 | post :create, :link => valid_attributes
72 | assigns(:link).should be_a(Link)
73 | assigns(:link).should be_persisted
74 | end
75 |
76 | it "redirects to the created link" do
77 | post :create, :link => valid_attributes
78 | response.should redirect_to(Link.last)
79 | end
80 | end
81 |
82 | describe "with invalid params" do
83 | it "assigns a newly created but unsaved link as @link" do
84 | # Trigger the behavior that occurs when invalid params are submitted
85 | Link.any_instance.stub(:save).and_return(false)
86 | post :create, :link => {}
87 | assigns(:link).should be_a_new(Link)
88 | end
89 |
90 | it "re-renders the 'new' template" do
91 | # Trigger the behavior that occurs when invalid params are submitted
92 | Link.any_instance.stub(:save).and_return(false)
93 | post :create, :link => {}
94 | response.should render_template("new")
95 | end
96 | end
97 | end
98 |
99 | describe "PUT update" do
100 | describe "with valid params" do
101 | it "updates the requested link" do
102 | link = Link.create! valid_attributes
103 | # Assuming there are no other links in the database, this
104 | # specifies that the Link created on the previous line
105 | # receives the :update_attributes message with whatever params are
106 | # submitted in the request.
107 | Link.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
108 | put :update, :id => link.id, :link => {'these' => 'params'}
109 | end
110 |
111 | it "assigns the requested link as @link" do
112 | link = Link.create! valid_attributes
113 | put :update, :id => link.id, :link => valid_attributes
114 | assigns(:link).should eq(link)
115 | end
116 |
117 | it "redirects to the link" do
118 | link = Link.create! valid_attributes
119 | put :update, :id => link.id, :link => valid_attributes
120 | response.should redirect_to(link)
121 | end
122 | end
123 |
124 | describe "with invalid params" do
125 | it "assigns the link as @link" do
126 | link = Link.create! valid_attributes
127 | # Trigger the behavior that occurs when invalid params are submitted
128 | Link.any_instance.stub(:save).and_return(false)
129 | put :update, :id => link.id, :link => {}
130 | assigns(:link).should eq(link)
131 | end
132 |
133 | it "re-renders the 'edit' template" do
134 | link = Link.create! valid_attributes
135 | # Trigger the behavior that occurs when invalid params are submitted
136 | Link.any_instance.stub(:save).and_return(false)
137 | put :update, :id => link.id, :link => {}
138 | response.should render_template("edit")
139 | end
140 | end
141 | end
142 |
143 | describe "DELETE destroy" do
144 | it "destroys the requested link" do
145 | link = Link.create! valid_attributes
146 | expect {
147 | delete :destroy, :id => link.id
148 | }.to change(Link, :count).by(-1)
149 | end
150 |
151 | it "redirects to the links list" do
152 | link = Link.create! valid_attributes
153 | delete :destroy, :id => link.id
154 | response.should redirect_to(links_url)
155 | end
156 | end
157 |
158 | end
159 |
--------------------------------------------------------------------------------
/spec/controllers/tags_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # This spec was generated by rspec-rails when you ran the scaffold generator.
5 | # It demonstrates how one might use RSpec to specify the controller code that
6 | # was generated by Rails when you ran the scaffold generator.
7 | #
8 | # It assumes that the implementation code is generated by the rails scaffold
9 | # generator. If you are using any extension libraries to generate different
10 | # controller code, this generated spec may or may not pass.
11 | #
12 | # It only uses APIs available in rails and/or rspec-rails. There are a number
13 | # of tools you can use to make these specs even more expressive, but we're
14 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
15 | #
16 | # Compared to earlier versions of this generator, there is very limited use of
17 | # stubs and message expectations in this spec. Stubs are only used when there
18 | # is no simpler way to get a handle on the object needed for the example.
19 | # Message expectations are only used when there is no simpler way to specify
20 | # that an instance is receiving a specific message.
21 |
22 | describe TagsController do
23 |
24 | # This should return the minimal set of attributes required to create a valid
25 | # Tag. As you add validations to Tag, be sure to
26 | # update the return value of this method accordingly.
27 | def valid_attributes
28 | {}
29 | end
30 |
31 | describe "GET index" do
32 | it "assigns all tags as @tags" do
33 | tag = Tag.create! valid_attributes
34 | get :index
35 | assigns(:tags).should eq([tag])
36 | end
37 | end
38 |
39 | describe "GET show" do
40 | it "assigns the requested tag as @tag" do
41 | tag = Tag.create! valid_attributes
42 | get :show, :id => tag.id
43 | assigns(:tag).should eq(tag)
44 | end
45 | end
46 |
47 | describe "GET new" do
48 | it "assigns a new tag as @tag" do
49 | get :new
50 | assigns(:tag).should be_a_new(Tag)
51 | end
52 | end
53 |
54 | describe "GET edit" do
55 | it "assigns the requested tag as @tag" do
56 | tag = Tag.create! valid_attributes
57 | get :edit, :id => tag.id
58 | assigns(:tag).should eq(tag)
59 | end
60 | end
61 |
62 | describe "POST create" do
63 | describe "with valid params" do
64 | it "creates a new Tag" do
65 | expect {
66 | post :create, :tag => valid_attributes
67 | }.to change(Tag, :count).by(1)
68 | end
69 |
70 | it "assigns a newly created tag as @tag" do
71 | post :create, :tag => valid_attributes
72 | assigns(:tag).should be_a(Tag)
73 | assigns(:tag).should be_persisted
74 | end
75 |
76 | it "redirects to the created tag" do
77 | post :create, :tag => valid_attributes
78 | response.should redirect_to(Tag.last)
79 | end
80 | end
81 |
82 | describe "with invalid params" do
83 | it "assigns a newly created but unsaved tag as @tag" do
84 | # Trigger the behavior that occurs when invalid params are submitted
85 | Tag.any_instance.stub(:save).and_return(false)
86 | post :create, :tag => {}
87 | assigns(:tag).should be_a_new(Tag)
88 | end
89 |
90 | it "re-renders the 'new' template" do
91 | # Trigger the behavior that occurs when invalid params are submitted
92 | Tag.any_instance.stub(:save).and_return(false)
93 | post :create, :tag => {}
94 | response.should render_template("new")
95 | end
96 | end
97 | end
98 |
99 | describe "PUT update" do
100 | describe "with valid params" do
101 | it "updates the requested tag" do
102 | tag = Tag.create! valid_attributes
103 | # Assuming there are no other tags in the database, this
104 | # specifies that the Tag created on the previous line
105 | # receives the :update_attributes message with whatever params are
106 | # submitted in the request.
107 | Tag.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
108 | put :update, :id => tag.id, :tag => {'these' => 'params'}
109 | end
110 |
111 | it "assigns the requested tag as @tag" do
112 | tag = Tag.create! valid_attributes
113 | put :update, :id => tag.id, :tag => valid_attributes
114 | assigns(:tag).should eq(tag)
115 | end
116 |
117 | it "redirects to the tag" do
118 | tag = Tag.create! valid_attributes
119 | put :update, :id => tag.id, :tag => valid_attributes
120 | response.should redirect_to(tag)
121 | end
122 | end
123 |
124 | describe "with invalid params" do
125 | it "assigns the tag as @tag" do
126 | tag = Tag.create! valid_attributes
127 | # Trigger the behavior that occurs when invalid params are submitted
128 | Tag.any_instance.stub(:save).and_return(false)
129 | put :update, :id => tag.id, :tag => {}
130 | assigns(:tag).should eq(tag)
131 | end
132 |
133 | it "re-renders the 'edit' template" do
134 | tag = Tag.create! valid_attributes
135 | # Trigger the behavior that occurs when invalid params are submitted
136 | Tag.any_instance.stub(:save).and_return(false)
137 | put :update, :id => tag.id, :tag => {}
138 | response.should render_template("edit")
139 | end
140 | end
141 | end
142 |
143 | describe "DELETE destroy" do
144 | it "destroys the requested tag" do
145 | tag = Tag.create! valid_attributes
146 | expect {
147 | delete :destroy, :id => tag.id
148 | }.to change(Tag, :count).by(-1)
149 | end
150 |
151 | it "redirects to the tags list" do
152 | tag = Tag.create! valid_attributes
153 | delete :destroy, :id => tag.id
154 | response.should redirect_to(tags_url)
155 | end
156 | end
157 |
158 | end
159 |
--------------------------------------------------------------------------------
/spec/controllers/tweets_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # This spec was generated by rspec-rails when you ran the scaffold generator.
5 | # It demonstrates how one might use RSpec to specify the controller code that
6 | # was generated by Rails when you ran the scaffold generator.
7 | #
8 | # It assumes that the implementation code is generated by the rails scaffold
9 | # generator. If you are using any extension libraries to generate different
10 | # controller code, this generated spec may or may not pass.
11 | #
12 | # It only uses APIs available in rails and/or rspec-rails. There are a number
13 | # of tools you can use to make these specs even more expressive, but we're
14 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
15 | #
16 | # Compared to earlier versions of this generator, there is very limited use of
17 | # stubs and message expectations in this spec. Stubs are only used when there
18 | # is no simpler way to get a handle on the object needed for the example.
19 | # Message expectations are only used when there is no simpler way to specify
20 | # that an instance is receiving a specific message.
21 |
22 | describe TweetsController do
23 |
24 | # This should return the minimal set of attributes required to create a valid
25 | # Tweet. As you add validations to Tweet, be sure to
26 | # update the return value of this method accordingly.
27 | def valid_attributes
28 | {}
29 | end
30 |
31 | describe "GET index" do
32 | it "assigns all tweets as @tweets" do
33 | tweet = Tweet.create! valid_attributes
34 | get :index
35 | assigns(:tweets).should eq([tweet])
36 | end
37 | end
38 |
39 | describe "GET show" do
40 | it "assigns the requested tweet as @tweet" do
41 | tweet = Tweet.create! valid_attributes
42 | get :show, :id => tweet.id
43 | assigns(:tweet).should eq(tweet)
44 | end
45 | end
46 |
47 | describe "GET new" do
48 | it "assigns a new tweet as @tweet" do
49 | get :new
50 | assigns(:tweet).should be_a_new(Tweet)
51 | end
52 | end
53 |
54 | describe "GET edit" do
55 | it "assigns the requested tweet as @tweet" do
56 | tweet = Tweet.create! valid_attributes
57 | get :edit, :id => tweet.id
58 | assigns(:tweet).should eq(tweet)
59 | end
60 | end
61 |
62 | describe "POST create" do
63 | describe "with valid params" do
64 | it "creates a new Tweet" do
65 | expect {
66 | post :create, :tweet => valid_attributes
67 | }.to change(Tweet, :count).by(1)
68 | end
69 |
70 | it "assigns a newly created tweet as @tweet" do
71 | post :create, :tweet => valid_attributes
72 | assigns(:tweet).should be_a(Tweet)
73 | assigns(:tweet).should be_persisted
74 | end
75 |
76 | it "redirects to the created tweet" do
77 | post :create, :tweet => valid_attributes
78 | response.should redirect_to(Tweet.last)
79 | end
80 | end
81 |
82 | describe "with invalid params" do
83 | it "assigns a newly created but unsaved tweet as @tweet" do
84 | # Trigger the behavior that occurs when invalid params are submitted
85 | Tweet.any_instance.stub(:save).and_return(false)
86 | post :create, :tweet => {}
87 | assigns(:tweet).should be_a_new(Tweet)
88 | end
89 |
90 | it "re-renders the 'new' template" do
91 | # Trigger the behavior that occurs when invalid params are submitted
92 | Tweet.any_instance.stub(:save).and_return(false)
93 | post :create, :tweet => {}
94 | response.should render_template("new")
95 | end
96 | end
97 | end
98 |
99 | describe "PUT update" do
100 | describe "with valid params" do
101 | it "updates the requested tweet" do
102 | tweet = Tweet.create! valid_attributes
103 | # Assuming there are no other tweets in the database, this
104 | # specifies that the Tweet created on the previous line
105 | # receives the :update_attributes message with whatever params are
106 | # submitted in the request.
107 | Tweet.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
108 | put :update, :id => tweet.id, :tweet => {'these' => 'params'}
109 | end
110 |
111 | it "assigns the requested tweet as @tweet" do
112 | tweet = Tweet.create! valid_attributes
113 | put :update, :id => tweet.id, :tweet => valid_attributes
114 | assigns(:tweet).should eq(tweet)
115 | end
116 |
117 | it "redirects to the tweet" do
118 | tweet = Tweet.create! valid_attributes
119 | put :update, :id => tweet.id, :tweet => valid_attributes
120 | response.should redirect_to(tweet)
121 | end
122 | end
123 |
124 | describe "with invalid params" do
125 | it "assigns the tweet as @tweet" do
126 | tweet = Tweet.create! valid_attributes
127 | # Trigger the behavior that occurs when invalid params are submitted
128 | Tweet.any_instance.stub(:save).and_return(false)
129 | put :update, :id => tweet.id, :tweet => {}
130 | assigns(:tweet).should eq(tweet)
131 | end
132 |
133 | it "re-renders the 'edit' template" do
134 | tweet = Tweet.create! valid_attributes
135 | # Trigger the behavior that occurs when invalid params are submitted
136 | Tweet.any_instance.stub(:save).and_return(false)
137 | put :update, :id => tweet.id, :tweet => {}
138 | response.should render_template("edit")
139 | end
140 | end
141 | end
142 |
143 | describe "DELETE destroy" do
144 | it "destroys the requested tweet" do
145 | tweet = Tweet.create! valid_attributes
146 | expect {
147 | delete :destroy, :id => tweet.id
148 | }.to change(Tweet, :count).by(-1)
149 | end
150 |
151 | it "redirects to the tweets list" do
152 | tweet = Tweet.create! valid_attributes
153 | delete :destroy, :id => tweet.id
154 | response.should redirect_to(tweets_url)
155 | end
156 | end
157 |
158 | end
159 |
--------------------------------------------------------------------------------
/spec/controllers/users_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # This spec was generated by rspec-rails when you ran the scaffold generator.
5 | # It demonstrates how one might use RSpec to specify the controller code that
6 | # was generated by Rails when you ran the scaffold generator.
7 | #
8 | # It assumes that the implementation code is generated by the rails scaffold
9 | # generator. If you are using any extension libraries to generate different
10 | # controller code, this generated spec may or may not pass.
11 | #
12 | # It only uses APIs available in rails and/or rspec-rails. There are a number
13 | # of tools you can use to make these specs even more expressive, but we're
14 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
15 | #
16 | # Compared to earlier versions of this generator, there is very limited use of
17 | # stubs and message expectations in this spec. Stubs are only used when there
18 | # is no simpler way to get a handle on the object needed for the example.
19 | # Message expectations are only used when there is no simpler way to specify
20 | # that an instance is receiving a specific message.
21 |
22 | describe UsersController do
23 |
24 | # This should return the minimal set of attributes required to create a valid
25 | # User. As you add validations to User, be sure to
26 | # update the return value of this method accordingly.
27 | def valid_attributes
28 | {}
29 | end
30 |
31 | describe "GET index" do
32 | it "assigns all users as @users" do
33 | user = User.create! valid_attributes
34 | get :index
35 | assigns(:users).should eq([user])
36 | end
37 | end
38 |
39 | describe "GET show" do
40 | it "assigns the requested user as @user" do
41 | user = User.create! valid_attributes
42 | get :show, :id => user.id
43 | assigns(:user).should eq(user)
44 | end
45 | end
46 |
47 | describe "GET new" do
48 | it "assigns a new user as @user" do
49 | get :new
50 | assigns(:user).should be_a_new(User)
51 | end
52 | end
53 |
54 | describe "GET edit" do
55 | it "assigns the requested user as @user" do
56 | user = User.create! valid_attributes
57 | get :edit, :id => user.id
58 | assigns(:user).should eq(user)
59 | end
60 | end
61 |
62 | describe "POST create" do
63 | describe "with valid params" do
64 | it "creates a new User" do
65 | expect {
66 | post :create, :user => valid_attributes
67 | }.to change(User, :count).by(1)
68 | end
69 |
70 | it "assigns a newly created user as @user" do
71 | post :create, :user => valid_attributes
72 | assigns(:user).should be_a(User)
73 | assigns(:user).should be_persisted
74 | end
75 |
76 | it "redirects to the created user" do
77 | post :create, :user => valid_attributes
78 | response.should redirect_to(User.last)
79 | end
80 | end
81 |
82 | describe "with invalid params" do
83 | it "assigns a newly created but unsaved user as @user" do
84 | # Trigger the behavior that occurs when invalid params are submitted
85 | User.any_instance.stub(:save).and_return(false)
86 | post :create, :user => {}
87 | assigns(:user).should be_a_new(User)
88 | end
89 |
90 | it "re-renders the 'new' template" do
91 | # Trigger the behavior that occurs when invalid params are submitted
92 | User.any_instance.stub(:save).and_return(false)
93 | post :create, :user => {}
94 | response.should render_template("new")
95 | end
96 | end
97 | end
98 |
99 | describe "PUT update" do
100 | describe "with valid params" do
101 | it "updates the requested user" do
102 | user = User.create! valid_attributes
103 | # Assuming there are no other users in the database, this
104 | # specifies that the User created on the previous line
105 | # receives the :update_attributes message with whatever params are
106 | # submitted in the request.
107 | User.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
108 | put :update, :id => user.id, :user => {'these' => 'params'}
109 | end
110 |
111 | it "assigns the requested user as @user" do
112 | user = User.create! valid_attributes
113 | put :update, :id => user.id, :user => valid_attributes
114 | assigns(:user).should eq(user)
115 | end
116 |
117 | it "redirects to the user" do
118 | user = User.create! valid_attributes
119 | put :update, :id => user.id, :user => valid_attributes
120 | response.should redirect_to(user)
121 | end
122 | end
123 |
124 | describe "with invalid params" do
125 | it "assigns the user as @user" do
126 | user = User.create! valid_attributes
127 | # Trigger the behavior that occurs when invalid params are submitted
128 | User.any_instance.stub(:save).and_return(false)
129 | put :update, :id => user.id, :user => {}
130 | assigns(:user).should eq(user)
131 | end
132 |
133 | it "re-renders the 'edit' template" do
134 | user = User.create! valid_attributes
135 | # Trigger the behavior that occurs when invalid params are submitted
136 | User.any_instance.stub(:save).and_return(false)
137 | put :update, :id => user.id, :user => {}
138 | response.should render_template("edit")
139 | end
140 | end
141 | end
142 |
143 | describe "DELETE destroy" do
144 | it "destroys the requested user" do
145 | user = User.create! valid_attributes
146 | expect {
147 | delete :destroy, :id => user.id
148 | }.to change(User, :count).by(-1)
149 | end
150 |
151 | it "redirects to the users list" do
152 | user = User.create! valid_attributes
153 | delete :destroy, :id => user.id
154 | response.should redirect_to(users_url)
155 | end
156 | end
157 |
158 | end
159 |
--------------------------------------------------------------------------------
/spec/helpers/links_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # Specs in this file have access to a helper object that includes
5 | # the LinksHelper. For example:
6 | #
7 | # describe LinksHelper do
8 | # describe "string concat" do
9 | # it "concats two strings with spaces" do
10 | # helper.concat_strings("this","that").should == "this that"
11 | # end
12 | # end
13 | # end
14 | describe LinksHelper do
15 | pending "add some examples to (or delete) #{__FILE__}"
16 | end
17 |
--------------------------------------------------------------------------------
/spec/helpers/tags_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # Specs in this file have access to a helper object that includes
5 | # the TagsHelper. For example:
6 | #
7 | # describe TagsHelper do
8 | # describe "string concat" do
9 | # it "concats two strings with spaces" do
10 | # helper.concat_strings("this","that").should == "this that"
11 | # end
12 | # end
13 | # end
14 | describe TagsHelper do
15 | pending "add some examples to (or delete) #{__FILE__}"
16 | end
17 |
--------------------------------------------------------------------------------
/spec/helpers/tweets_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # Specs in this file have access to a helper object that includes
5 | # the TweetsHelper. For example:
6 | #
7 | # describe TweetsHelper do
8 | # describe "string concat" do
9 | # it "concats two strings with spaces" do
10 | # helper.concat_strings("this","that").should == "this that"
11 | # end
12 | # end
13 | # end
14 | describe TweetsHelper do
15 | pending "add some examples to (or delete) #{__FILE__}"
16 | end
17 |
--------------------------------------------------------------------------------
/spec/helpers/users_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | # Specs in this file have access to a helper object that includes
5 | # the UsersHelper. For example:
6 | #
7 | # describe UsersHelper do
8 | # describe "string concat" do
9 | # it "concats two strings with spaces" do
10 | # helper.concat_strings("this","that").should == "this that"
11 | # end
12 | # end
13 | # end
14 | describe UsersHelper do
15 | pending "add some examples to (or delete) #{__FILE__}"
16 | end
17 |
--------------------------------------------------------------------------------
/spec/models/link_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe Link do
5 | pending "add some examples to (or delete) #{__FILE__}"
6 | end
7 |
--------------------------------------------------------------------------------
/spec/models/tag_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe Tag do
5 | pending "add some examples to (or delete) #{__FILE__}"
6 | end
7 |
--------------------------------------------------------------------------------
/spec/models/tweet_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe Tweet do
5 | pending "add some examples to (or delete) #{__FILE__}"
6 | end
7 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe User do
5 | pending "add some examples to (or delete) #{__FILE__}"
6 | end
7 |
--------------------------------------------------------------------------------
/spec/requests/links_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "Links" do
5 | describe "GET /links" do
6 | it "works! (now write some real specs)" do
7 | # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
8 | get links_path
9 | response.status.should be(200)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/requests/tags_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "Tags" do
5 | describe "GET /tags" do
6 | it "works! (now write some real specs)" do
7 | # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
8 | get tags_path
9 | response.status.should be(200)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/requests/tweets_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "Tweets" do
5 | describe "GET /tweets" do
6 | it "works! (now write some real specs)" do
7 | # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
8 | get tweets_path
9 | response.status.should be(200)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/requests/users_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "Users" do
5 | describe "GET /users" do
6 | it "works! (now write some real specs)" do
7 | # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
8 | get users_path
9 | response.status.should be(200)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/routing/links_routing_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require "spec_helper"
3 |
4 | describe LinksController do
5 | describe "routing" do
6 |
7 | it "routes to #index" do
8 | get("/links").should route_to("links#index")
9 | end
10 |
11 | it "routes to #new" do
12 | get("/links/new").should route_to("links#new")
13 | end
14 |
15 | it "routes to #show" do
16 | get("/links/1").should route_to("links#show", :id => "1")
17 | end
18 |
19 | it "routes to #edit" do
20 | get("/links/1/edit").should route_to("links#edit", :id => "1")
21 | end
22 |
23 | it "routes to #create" do
24 | post("/links").should route_to("links#create")
25 | end
26 |
27 | it "routes to #update" do
28 | put("/links/1").should route_to("links#update", :id => "1")
29 | end
30 |
31 | it "routes to #destroy" do
32 | delete("/links/1").should route_to("links#destroy", :id => "1")
33 | end
34 |
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/routing/tags_routing_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require "spec_helper"
3 |
4 | describe TagsController do
5 | describe "routing" do
6 |
7 | it "routes to #index" do
8 | get("/tags").should route_to("tags#index")
9 | end
10 |
11 | it "routes to #new" do
12 | get("/tags/new").should route_to("tags#new")
13 | end
14 |
15 | it "routes to #show" do
16 | get("/tags/1").should route_to("tags#show", :id => "1")
17 | end
18 |
19 | it "routes to #edit" do
20 | get("/tags/1/edit").should route_to("tags#edit", :id => "1")
21 | end
22 |
23 | it "routes to #create" do
24 | post("/tags").should route_to("tags#create")
25 | end
26 |
27 | it "routes to #update" do
28 | put("/tags/1").should route_to("tags#update", :id => "1")
29 | end
30 |
31 | it "routes to #destroy" do
32 | delete("/tags/1").should route_to("tags#destroy", :id => "1")
33 | end
34 |
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/routing/tweets_routing_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require "spec_helper"
3 |
4 | describe TweetsController do
5 | describe "routing" do
6 |
7 | it "routes to #index" do
8 | get("/tweets").should route_to("tweets#index")
9 | end
10 |
11 | it "routes to #new" do
12 | get("/tweets/new").should route_to("tweets#new")
13 | end
14 |
15 | it "routes to #show" do
16 | get("/tweets/1").should route_to("tweets#show", :id => "1")
17 | end
18 |
19 | it "routes to #edit" do
20 | get("/tweets/1/edit").should route_to("tweets#edit", :id => "1")
21 | end
22 |
23 | it "routes to #create" do
24 | post("/tweets").should route_to("tweets#create")
25 | end
26 |
27 | it "routes to #update" do
28 | put("/tweets/1").should route_to("tweets#update", :id => "1")
29 | end
30 |
31 | it "routes to #destroy" do
32 | delete("/tweets/1").should route_to("tweets#destroy", :id => "1")
33 | end
34 |
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/routing/users_routing_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require "spec_helper"
3 |
4 | describe UsersController do
5 | describe "routing" do
6 |
7 | it "routes to #index" do
8 | get("/users").should route_to("users#index")
9 | end
10 |
11 | it "routes to #new" do
12 | get("/users/new").should route_to("users#new")
13 | end
14 |
15 | it "routes to #show" do
16 | get("/users/1").should route_to("users#show", :id => "1")
17 | end
18 |
19 | it "routes to #edit" do
20 | get("/users/1/edit").should route_to("users#edit", :id => "1")
21 | end
22 |
23 | it "routes to #create" do
24 | post("/users").should route_to("users#create")
25 | end
26 |
27 | it "routes to #update" do
28 | put("/users/1").should route_to("users#update", :id => "1")
29 | end
30 |
31 | it "routes to #destroy" do
32 | delete("/users/1").should route_to("users#destroy", :id => "1")
33 | end
34 |
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/spec/views/links/edit.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "links/edit.html.erb" do
5 | before(:each) do
6 | @link = assign(:link, stub_model(Link,
7 | :url => "MyString"
8 | ))
9 | end
10 |
11 | it "renders the edit link form" do
12 | render
13 |
14 | # Run the generator again with the --webrat flag if you want to use webrat matchers
15 | assert_select "form", :action => links_path(@link), :method => "post" do
16 | assert_select "input#link_url", :name => "link[url]"
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/views/links/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "links/index.html.erb" do
5 | before(:each) do
6 | assign(:links, [
7 | stub_model(Link,
8 | :url => "Url"
9 | ),
10 | stub_model(Link,
11 | :url => "Url"
12 | )
13 | ])
14 | end
15 |
16 | it "renders a list of links" do
17 | render
18 | # Run the generator again with the --webrat flag if you want to use webrat matchers
19 | assert_select "tr>td", :text => "Url".to_s, :count => 2
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/views/links/new.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "links/new.html.erb" do
5 | before(:each) do
6 | assign(:link, stub_model(Link,
7 | :url => "MyString"
8 | ).as_new_record)
9 | end
10 |
11 | it "renders new link form" do
12 | render
13 |
14 | # Run the generator again with the --webrat flag if you want to use webrat matchers
15 | assert_select "form", :action => links_path, :method => "post" do
16 | assert_select "input#link_url", :name => "link[url]"
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/views/links/show.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "links/show.html.erb" do
5 | before(:each) do
6 | @link = assign(:link, stub_model(Link,
7 | :url => "Url"
8 | ))
9 | end
10 |
11 | it "renders attributes in
" do
12 | render
13 | # Run the generator again with the --webrat flag if you want to use webrat matchers
14 | rendered.should match(/Url/)
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/views/tags/edit.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tags/edit.html.erb" do
5 | before(:each) do
6 | @tag = assign(:tag, stub_model(Tag,
7 | :name => "MyString"
8 | ))
9 | end
10 |
11 | it "renders the edit tag form" do
12 | render
13 |
14 | # Run the generator again with the --webrat flag if you want to use webrat matchers
15 | assert_select "form", :action => tags_path(@tag), :method => "post" do
16 | assert_select "input#tag_name", :name => "tag[name]"
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/views/tags/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tags/index.html.erb" do
5 | before(:each) do
6 | assign(:tags, [
7 | stub_model(Tag,
8 | :name => "Name"
9 | ),
10 | stub_model(Tag,
11 | :name => "Name"
12 | )
13 | ])
14 | end
15 |
16 | it "renders a list of tags" do
17 | render
18 | # Run the generator again with the --webrat flag if you want to use webrat matchers
19 | assert_select "tr>td", :text => "Name".to_s, :count => 2
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/views/tags/new.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tags/new.html.erb" do
5 | before(:each) do
6 | assign(:tag, stub_model(Tag,
7 | :name => "MyString"
8 | ).as_new_record)
9 | end
10 |
11 | it "renders new tag form" do
12 | render
13 |
14 | # Run the generator again with the --webrat flag if you want to use webrat matchers
15 | assert_select "form", :action => tags_path, :method => "post" do
16 | assert_select "input#tag_name", :name => "tag[name]"
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/views/tags/show.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tags/show.html.erb" do
5 | before(:each) do
6 | @tag = assign(:tag, stub_model(Tag,
7 | :name => "Name"
8 | ))
9 | end
10 |
11 | it "renders attributes in
" do
12 | render
13 | # Run the generator again with the --webrat flag if you want to use webrat matchers
14 | rendered.should match(/Name/)
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/views/tweets/edit.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tweets/edit.html.erb" do
5 | before(:each) do
6 | @tweet = assign(:tweet, stub_model(Tweet,
7 | :text => "MyString",
8 | :link => "MyString",
9 | :tweet_id => "MyString"
10 | ))
11 | end
12 |
13 | it "renders the edit tweet form" do
14 | render
15 |
16 | # Run the generator again with the --webrat flag if you want to use webrat matchers
17 | assert_select "form", :action => tweets_path(@tweet), :method => "post" do
18 | assert_select "input#tweet_text", :name => "tweet[text]"
19 | assert_select "input#tweet_link", :name => "tweet[link]"
20 | assert_select "input#tweet_tweet_id", :name => "tweet[tweet_id]"
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/views/tweets/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tweets/index.html.erb" do
5 | before(:each) do
6 | assign(:tweets, [
7 | stub_model(Tweet,
8 | :text => "Text",
9 | :link => "Link",
10 | :tweet_id => "Tweet"
11 | ),
12 | stub_model(Tweet,
13 | :text => "Text",
14 | :link => "Link",
15 | :tweet_id => "Tweet"
16 | )
17 | ])
18 | end
19 |
20 | it "renders a list of tweets" do
21 | render
22 | # Run the generator again with the --webrat flag if you want to use webrat matchers
23 | assert_select "tr>td", :text => "Text".to_s, :count => 2
24 | # Run the generator again with the --webrat flag if you want to use webrat matchers
25 | assert_select "tr>td", :text => "Link".to_s, :count => 2
26 | # Run the generator again with the --webrat flag if you want to use webrat matchers
27 | assert_select "tr>td", :text => "Tweet".to_s, :count => 2
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/spec/views/tweets/new.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tweets/new.html.erb" do
5 | before(:each) do
6 | assign(:tweet, stub_model(Tweet,
7 | :text => "MyString",
8 | :link => "MyString",
9 | :tweet_id => "MyString"
10 | ).as_new_record)
11 | end
12 |
13 | it "renders new tweet form" do
14 | render
15 |
16 | # Run the generator again with the --webrat flag if you want to use webrat matchers
17 | assert_select "form", :action => tweets_path, :method => "post" do
18 | assert_select "input#tweet_text", :name => "tweet[text]"
19 | assert_select "input#tweet_link", :name => "tweet[link]"
20 | assert_select "input#tweet_tweet_id", :name => "tweet[tweet_id]"
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/views/tweets/show.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "tweets/show.html.erb" do
5 | before(:each) do
6 | @tweet = assign(:tweet, stub_model(Tweet,
7 | :text => "Text",
8 | :link => "Link",
9 | :tweet_id => "Tweet"
10 | ))
11 | end
12 |
13 | it "renders attributes in
" do
14 | render
15 | # Run the generator again with the --webrat flag if you want to use webrat matchers
16 | rendered.should match(/Text/)
17 | # Run the generator again with the --webrat flag if you want to use webrat matchers
18 | rendered.should match(/Link/)
19 | # Run the generator again with the --webrat flag if you want to use webrat matchers
20 | rendered.should match(/Tweet/)
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/views/users/edit.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "users/edit.html.erb" do
5 | before(:each) do
6 | @user = assign(:user, stub_model(User,
7 | :twid => "MyString",
8 | :link => "MyString"
9 | ))
10 | end
11 |
12 | it "renders the edit user form" do
13 | render
14 |
15 | # Run the generator again with the --webrat flag if you want to use webrat matchers
16 | assert_select "form", :action => users_path(@user), :method => "post" do
17 | assert_select "input#user_twid", :name => "user[twid]"
18 | assert_select "input#user_link", :name => "user[link]"
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/views/users/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "users/index.html.erb" do
5 | before(:each) do
6 | assign(:users, [
7 | stub_model(User,
8 | :twid => "Twid",
9 | :link => "Link"
10 | ),
11 | stub_model(User,
12 | :twid => "Twid",
13 | :link => "Link"
14 | )
15 | ])
16 | end
17 |
18 | it "renders a list of users" do
19 | render
20 | # Run the generator again with the --webrat flag if you want to use webrat matchers
21 | assert_select "tr>td", :text => "Twid".to_s, :count => 2
22 | # Run the generator again with the --webrat flag if you want to use webrat matchers
23 | assert_select "tr>td", :text => "Link".to_s, :count => 2
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/views/users/new.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "users/new.html.erb" do
5 | before(:each) do
6 | assign(:user, stub_model(User,
7 | :twid => "MyString",
8 | :link => "MyString"
9 | ).as_new_record)
10 | end
11 |
12 | it "renders new user form" do
13 | render
14 |
15 | # Run the generator again with the --webrat flag if you want to use webrat matchers
16 | assert_select "form", :action => users_path, :method => "post" do
17 | assert_select "input#user_twid", :name => "user[twid]"
18 | assert_select "input#user_link", :name => "user[link]"
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/spec/views/users/show.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'spec_helper'
3 |
4 | describe "users/show.html.erb" do
5 | before(:each) do
6 | @user = assign(:user, stub_model(User,
7 | :twid => "Twid",
8 | :link => "Link"
9 | ))
10 | end
11 |
12 | it "renders attributes in
" do
13 | render
14 | # Run the generator again with the --webrat flag if you want to use webrat matchers
15 | rendered.should match(/Twid/)
16 | # Run the generator again with the --webrat flag if you want to use webrat matchers
17 | rendered.should match(/Link/)
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/test/fixtures/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/test/fixtures/.gitkeep
--------------------------------------------------------------------------------
/test/functional/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/test/functional/.gitkeep
--------------------------------------------------------------------------------
/test/integration/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/test/integration/.gitkeep
--------------------------------------------------------------------------------
/test/performance/browsing_test.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | require 'test_helper'
3 | require 'rails/performance_test_help'
4 |
5 | class BrowsingTest < ActionDispatch::PerformanceTest
6 | # Refer to the documentation for all available options
7 | # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
8 | # :output => 'tmp/performance', :formats => [:flat] }
9 |
10 | def test_homepage
11 | get '/'
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | # -*- encoding : utf-8 -*-
2 | ENV["RAILS_ENV"] = "test"
3 | require File.expand_path('../../config/environment', __FILE__)
4 | require 'rails/test_help'
5 |
6 | class ActiveSupport::TestCase
7 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
8 | #
9 | # Note: You'll currently still have to declare fixtures explicitly in integration tests
10 | # -- they do not yet inherit this setting
11 | fixtures :all
12 |
13 | # Add more helper methods to be used by all tests here...
14 | end
15 |
--------------------------------------------------------------------------------
/test/unit/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/test/unit/.gitkeep
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/vendor/assets/stylesheets/.gitkeep
--------------------------------------------------------------------------------
/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo4jrb/kvitter/507cd0920b6a8b289f4d896ec8a87a70584cfc83/vendor/plugins/.gitkeep
--------------------------------------------------------------------------------