From 5ee724b7546305c4f82f899fd368a5b97416b29a Mon Sep 17 00:00:00 2001 From: Dan Matthews Date: Thu, 31 Oct 2013 11:54:51 -0400 Subject: [PATCH] Changing language to Twetter and Twet --- README.md | 12 ++-- Rakefile | 2 +- app/assets/images/twetter-logo.png | Bin 0 -> 512 bytes .../{tweets.js.coffee => twets.js.coffee} | 0 app/assets/stylesheets/style.css | 4 +- .../{tweets.css.scss => twets.css.scss} | 2 +- app/controllers/tweets_controller.rb | 57 ------------------ app/controllers/twets_controller.rb | 57 ++++++++++++++++++ app/helpers/application_helper.rb | 4 +- app/helpers/tweets_helper.rb | 2 - app/helpers/twets_helper.rb | 2 + app/models/{tweet.rb => twet.rb} | 6 +- app/models/user.rb | 8 +-- app/views/follows/index.html.erb | 2 +- app/views/home/_sign_up.html.erb | 4 +- app/views/layouts/application.html.erb | 2 +- app/views/shared/_left_nav.html.erb | 12 ++-- app/views/tweets/index.html.erb | 26 -------- app/views/twets/index.html.erb | 26 ++++++++ config/application.rb | 2 +- config/environment.rb | 2 +- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- config/environments/test.rb | 2 +- config/initializers/session_store.rb | 2 +- config/routes.rb | 4 +- .../20131031152306_change_tweet_to_twet.rb | 9 +++ db/schema.rb | 6 +- lib/tasks/seed.rake | 6 +- ...oller_spec.rb => twets_controller_spec.rb} | 18 +++--- spec/factories/{tweets.rb => twets.rb} | 2 +- ...ts_helper_spec.rb => twets_helper_spec.rb} | 6 +- spec/models/{tweet_spec.rb => twet_spec.rb} | 24 ++++---- spec/models/user_spec.rb | 14 ++--- 34 files changed, 169 insertions(+), 160 deletions(-) create mode 100644 app/assets/images/twetter-logo.png rename app/assets/javascripts/{tweets.js.coffee => twets.js.coffee} (100%) rename app/assets/stylesheets/{tweets.css.scss => twets.css.scss} (64%) delete mode 100644 app/controllers/tweets_controller.rb create mode 100644 app/controllers/twets_controller.rb delete mode 100644 app/helpers/tweets_helper.rb create mode 100644 app/helpers/twets_helper.rb rename app/models/{tweet.rb => twet.rb} (63%) delete mode 100644 app/views/tweets/index.html.erb create mode 100644 app/views/twets/index.html.erb create mode 100644 db/migrate/20131031152306_change_tweet_to_twet.rb rename spec/controllers/{tweets_controller_spec.rb => twets_controller_spec.rb} (64%) rename spec/factories/{tweets.rb => twets.rb} (90%) rename spec/helpers/{tweets_helper_spec.rb => twets_helper_spec.rb} (75%) rename spec/models/{tweet_spec.rb => twet_spec.rb} (55%) diff --git a/README.md b/README.md index d29f0ed..6440205 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -twitter-clone +Twetter ============= -This is the sample Twitter Clone code base for Thinkful's Ruby on Rails course. +This is the sample version of Twetter, a basic clone of the most popular micro-blogging site, produced for Thinkful's Ruby on Rails course. Before Beginning ------------- @@ -24,15 +24,15 @@ Getting Started ```sh # Clone the repository -git clone git@github.com:Thinkful/twitter-clone.git +git clone git@github.com:Thinkful/twetter.git -cd ./twitter-clone +cd ./twetter # Install the required gems bundle install # Generate a new config/initializers/secret_token.rb file. -echo "TwitterClone::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb +echo "Twetter::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb # Set up the database bundle exec rake db:create db:migrate db:test:prepare @@ -50,7 +50,7 @@ Seeds ```sh bundle exec rake seed:users # Create 20 users -bundle exec rake seed:tweets # Create 5 tweets for each user +bundle exec rake seed:twets # Create 5 twets for each user ``` If you'd like to log in as one of your recently seeded users, use the rails console to diff --git a/Rakefile b/Rakefile index 9be8df9..4949079 100644 --- a/Rakefile +++ b/Rakefile @@ -3,4 +3,4 @@ require File.expand_path('../config/application', __FILE__) -TwitterClone::Application.load_tasks +Twetter::Application.load_tasks diff --git a/app/assets/images/twetter-logo.png b/app/assets/images/twetter-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..87fccbc975872431e691ff4a61f1f74d7905b2f2 GIT binary patch literal 512 zcmV+b0{{JqP)ubvvewfCQB% zaD2E6YRdzOi89X{ySKsK!DO4A^Fjmz;Z#V*G~bN45rRf8S|=l7t^vs{jC%$@lL6hn z0SZpUb(_eQL-Z&Ce~ayqHMK}hZMPH%V8TQ9iFP~w(|v*8Py3ubk4F3b;q(I1=p~Dv zlUVh_qwj)ZqK@~=>uDcMw8U%19+1RXf>0e<)`W=7l_|v>>^lE}qr@m&!*Q-xC8*?_ z-TRRBI|ihah^x0K(&=h#FPWfje1lkK{2(^q^xY3Y!o43cvR?=Q0000 All tweets defaultly shown to the authenticated user. - # - def index - get_tweets - end - - # POST /tweets - # - # Used to create a new tweet for the authenticated user based on the data passed - # in params[:tweet]. If the tweet is created successfully, a success message is - # set and we are directed to the index action. Otherwise, an error message is set, - # the tweets visible to the authenticated user are loaded into @tweets and the index - # view template is displayed. - # - # @tweet # => The newly created (or attempted) tweet. - # @tweets # => (only set if the tweet was not created) All tweets defaultly shown - # to the authenticated user. - # - # - def create - @tweet = current_user.tweets.create(tweet_params) - if @tweet.valid? - flash[:success] = "Your tweet was shared" - redirect_to :action => :index and return - else - get_tweets - flash[:error] = "Your tweet could not be saved" - render :action => :index and return - end - end - - private - - # Sets the @tweets instance variable to all tweets viewable by the current user - def get_tweets - @tweets = current_user.all_tweets - end - - # http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters - # - # This method uses Strong Parameters to ensure that the data passed by the user - # is appropriate. If params[:tweet] does not exist or contains any key / value - # pairs other then :content, an error will be raised and the page will return - # a 400 'Bad Request' HTML response code. - # - def tweet_params - params.require(:tweet).permit(:content) - end -end diff --git a/app/controllers/twets_controller.rb b/app/controllers/twets_controller.rb new file mode 100644 index 0000000..2266efd --- /dev/null +++ b/app/controllers/twets_controller.rb @@ -0,0 +1,57 @@ +class TwetsController < ApplicationController + # All actions in this controller require the presence of an authenticated user. + before_filter :authenticate_user! + + # GET /twets + # + # This action uses the #get_twets method to set the @twets instance variable. + # + # @twets # => All twets defaultly shown to the authenticated user. + # + def index + get_twets + end + + # POST /twets + # + # Used to create a new twet for the authenticated user based on the data passed + # in params[:twet]. If the twet is created successfully, a success message is + # set and we are directed to the index action. Otherwise, an error message is set, + # the twets visible to the authenticated user are loaded into @twets and the index + # view template is displayed. + # + # @twet # => The newly created (or attempted) twet. + # @twets # => (only set if the twet was not created) All twets defaultly shown + # to the authenticated user. + # + # + def create + @twet = current_user.twets.create(twet_params) + if @twet.valid? + flash[:success] = "Your twet was shared" + redirect_to :action => :index and return + else + get_twets + flash[:error] = "Your twet could not be saved" + render :action => :index and return + end + end + + private + + # Sets the @twets instance variable to all twets viewable by the current user + def get_twets + @twets = current_user.all_twets + end + + # http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters + # + # This method uses Strong Parameters to ensure that the data passed by the user + # is appropriate. If params[:twet] does not exist or contains any key / value + # pairs other then :content, an error will be raised and the page will return + # a 400 'Bad Request' HTML response code. + # + def twet_params + params.require(:twet).permit(:content) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d12f55f..af78764 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,8 +48,8 @@ def active_class(name) case name when "Follow" then controller_name == 'follows' ? 'active' : '' - when "Tweet" then - controller_name == 'tweets' ? 'active' : '' + when "Twet" then + controller_name == 'twets' ? 'active' : '' end end diff --git a/app/helpers/tweets_helper.rb b/app/helpers/tweets_helper.rb deleted file mode 100644 index 6b7d657..0000000 --- a/app/helpers/tweets_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TweetsHelper -end diff --git a/app/helpers/twets_helper.rb b/app/helpers/twets_helper.rb new file mode 100644 index 0000000..b9eb842 --- /dev/null +++ b/app/helpers/twets_helper.rb @@ -0,0 +1,2 @@ +module TwetsHelper +end diff --git a/app/models/tweet.rb b/app/models/twet.rb similarity index 63% rename from app/models/tweet.rb rename to app/models/twet.rb index cf01ca4..9891cf8 100644 --- a/app/models/tweet.rb +++ b/app/models/twet.rb @@ -1,11 +1,11 @@ -class Tweet < ActiveRecord::Base +class Twet < ActiveRecord::Base belongs_to :user validates :content, :presence => true, :length => { :minimum => 2, :maximum => 140 } validates :user, :presence => true - # Gets all tweets made by the users referenced by the ids passed, starting with the - # most recent tweet made. + # Gets all twets made by the users referenced by the ids passed, starting with the + # most recent twet made. # def self.by_user_ids(*ids) where(:user_id => ids.flatten.compact.uniq).order('created_at DESC') diff --git a/app/models/user.rb b/app/models/user.rb index 5202af8..1421a84 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable has_many :follows - has_many :tweets + has_many :twets validates :name, :presence => true validates :username, :presence => true, :uniqueness => true @@ -15,10 +15,10 @@ def self.all_except(user) User.where(arel_table[:id].not_eq(user.id)).order(:name) end - # Leverages Tweet.by_user_ids to return all tweets created by this user + # Leverages Twet.by_user_ids to return all twets created by this user # and all users that this user follows. # - def all_tweets - Tweet.by_user_ids(id, *follows.map(&:following_id)) + def all_twets + Twet.by_user_ids(id, *follows.map(&:following_id)) end end diff --git a/app/views/follows/index.html.erb b/app/views/follows/index.html.erb index c6ca162..3c9a743 100644 --- a/app/views/follows/index.html.erb +++ b/app/views/follows/index.html.erb @@ -6,7 +6,7 @@

Who to follow

-

Twitter accounts in alpabetical order.

+

Twetter accounts in alpabetical order.


diff --git a/app/views/home/_sign_up.html.erb b/app/views/home/_sign_up.html.erb index 41a3e38..64c0e86 100644 --- a/app/views/home/_sign_up.html.erb +++ b/app/views/home/_sign_up.html.erb @@ -1,7 +1,7 @@
-

New to Twitter? Sign up

+

New to Twetter? Sign up


@@ -31,7 +31,7 @@ <% end %>
- <%= f.submit "Sign up for Twitter", :class => "btn btn-warning pull-right" %> + <%= f.submit "Sign up for Twetter", :class => "btn btn-warning pull-right" %>
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index beff475..ab10c8e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - Twitter Clone + Twetter <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> diff --git a/app/views/shared/_left_nav.html.erb b/app/views/shared/_left_nav.html.erb index 2ab7143..a630cf6 100644 --- a/app/views/shared/_left_nav.html.erb +++ b/app/views/shared/_left_nav.html.erb @@ -11,8 +11,8 @@ - <%= content_tag :h4, current_user.tweets.count %> - <%= content_tag :small, 'Tweets', :class => "uppercase lighter" %> + <%= content_tag :h4, current_user.twets.count %> + <%= content_tag :small, 'Twets', :class => "uppercase lighter" %> <%= content_tag :h4, current_user.follows.count %> @@ -26,23 +26,23 @@
  • - <%= form_for (@tweet || :tweet), :url => tweets_path, + <%= form_for (@twet || :twet), :url => twets_path, :builder => InlineErrorsBuilder, :method => :POST, :role => :form do |f| %>
    <%= content_tag :div, :class => f.validation_class(:content, "form-group") do %> - <%= f.text_area :content, :placeholder => "Compose new Tweet...", :class => 'form-control' %> + <%= f.text_area :content, :placeholder => "Compose new Twet...", :class => 'form-control' %> <%= f.errors_for :content %> <% end %> - <%= f.submit "Tweet", :class => "btn btn-primary pull-right" %> + <%= f.submit "Twet", :class => "btn btn-primary pull-right" %>
    <% end %>
  • diff --git a/app/views/tweets/index.html.erb b/app/views/tweets/index.html.erb deleted file mode 100644 index ffa1e04..0000000 --- a/app/views/tweets/index.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -
    -
    - - <%= render :partial => 'shared/left_nav' %> - -
    -
    -

    Tweets

    -
    -
    -
    -
      - <% @tweets.each do |tweet| -%> -
    1. - <%= content_tag :strong, tweet.user.name, :class => 'pull-left text-middle' %> - <%= content_tag :small, "@"+tweet.user.username, :class => 'text-muted pad-10 text-middle' %> - <%= content_tag :small, tweet.created_at.strftime("%b %-d"), :class => 'text-muted text-middle pull-right' %> -
      - <%= content_tag :p, tweet.content %> -
    2. -

    3. - <% end -%> -
    -
    -
    - diff --git a/app/views/twets/index.html.erb b/app/views/twets/index.html.erb new file mode 100644 index 0000000..7af60e1 --- /dev/null +++ b/app/views/twets/index.html.erb @@ -0,0 +1,26 @@ +
    +
    + + <%= render :partial => 'shared/left_nav' %> + +
    +
    +

    Twets

    +
    +
    +
    +
      + <% @twets.each do |twet| -%> +
    1. + <%= content_tag :strong, twet.user.name, :class => 'pull-left text-middle' %> + <%= content_tag :small, "@"+twet.user.username, :class => 'text-muted pad-10 text-middle' %> + <%= content_tag :small, twet.created_at.strftime("%b %-d"), :class => 'text-muted text-middle pull-right' %> +
      + <%= content_tag :p, twet.content %> +
    2. +

    3. + <% end -%> +
    +
    +
    + diff --git a/config/application.rb b/config/application.rb index c07f920..4364368 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,7 +6,7 @@ # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) -module TwitterClone +module Twetter class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/config/environment.rb b/config/environment.rb index fd0c661..7691f9a 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the Rails application. -TwitterClone::Application.initialize! +Twetter::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index f7efd4f..c4f5e1e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -TwitterClone::Application.configure do +Twetter::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on diff --git a/config/environments/production.rb b/config/environments/production.rb index 28a1a16..1bdfe3d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,4 @@ -TwitterClone::Application.configure do +Twetter::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. diff --git a/config/environments/test.rb b/config/environments/test.rb index b0f43e0..aef3f28 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -TwitterClone::Application.configure do +Twetter::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 085ae19..61f6af7 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -TwitterClone::Application.config.session_store :cookie_store, key: '_twitter-clone_session' +Twetter::Application.config.session_store :cookie_store, key: '_twetter_session' diff --git a/config/routes.rb b/config/routes.rb index 8a1b03a..98a293b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,11 @@ -TwitterClone::Application.routes.draw do +Twetter::Application.routes.draw do devise_for :users # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". authenticated :user do resources :follows, :except => [:new, :edit, :show, :update] - resources :tweets, :except => [:new, :edit, :show, :update] + resources :twets, :except => [:new, :edit, :show, :update] root :to => 'follows#index', :as => :user_root end diff --git a/db/migrate/20131031152306_change_tweet_to_twet.rb b/db/migrate/20131031152306_change_tweet_to_twet.rb new file mode 100644 index 0000000..c6e8f76 --- /dev/null +++ b/db/migrate/20131031152306_change_tweet_to_twet.rb @@ -0,0 +1,9 @@ +class ChangeTweetToTwet < ActiveRecord::Migration + def up + connection.execute("ALTER TABLE tweets RENAME TO twets;") + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index b28e499..f477a65 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20131027233836) do +ActiveRecord::Schema.define(version: 20131031152306) do create_table "follows", force: true do |t| t.integer "user_id" @@ -22,14 +22,14 @@ add_index "follows", ["user_id", "following_id"], name: "index_follows_on_user_id_and_following_id" - create_table "tweets", force: true do |t| + create_table "twets", force: true do |t| t.integer "user_id" t.string "content" t.datetime "created_at" t.datetime "updated_at" end - add_index "tweets", ["user_id"], name: "index_tweets_on_user_id" + add_index "twets", ["user_id"], name: "index_tweets_on_user_id" create_table "users", force: true do |t| t.string "email", default: "", null: false diff --git a/lib/tasks/seed.rake b/lib/tasks/seed.rake index 3093f34..80a7379 100644 --- a/lib/tasks/seed.rake +++ b/lib/tasks/seed.rake @@ -1,11 +1,11 @@ require 'ffaker' namespace :seed do - desc "Create 5 tweets for each user" - task :tweets => :environment do + desc "Create 5 twets for each user" + task :twets => :environment do User.find_each do |user| 5.times do - Tweet.create(:user => user, :content => Faker::Lorem.sentence(3)) + Twet.create(:user => user, :content => Faker::Lorem.sentence(3)) end end end diff --git a/spec/controllers/tweets_controller_spec.rb b/spec/controllers/twets_controller_spec.rb similarity index 64% rename from spec/controllers/tweets_controller_spec.rb rename to spec/controllers/twets_controller_spec.rb index ef88838..5038e66 100644 --- a/spec/controllers/tweets_controller_spec.rb +++ b/spec/controllers/twets_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe TweetsController do +describe TwetsController do context "when no user is logged in" do describe "GET index" do subject { response } @@ -12,7 +12,7 @@ describe "POST create" do subject { response } - before { post :create, :tweet => { :content => "Hello World!" } } + before { post :create, :twet => { :content => "Hello World!" } } it { should_not be_successful } end @@ -30,28 +30,28 @@ it { should be_successful } - it "should assign @tweets" do - assigns[:tweets].should_not be_nil + it "should assign @twets" do + assigns[:twets].should_not be_nil end end describe "POST create" do let(:following) { FactoryGirl.create(:user) } - before { post :create, :tweet => { :content => "Hello World!" } } + before { post :create, :twet => { :content => "Hello World!" } } it "should redirect to GET index" do - response.should redirect_to tweets_path + response.should redirect_to twets_path end it "should display a success message" do - flash[:success].should == "Your tweet was shared" + flash[:success].should == "Your twet was shared" end it "should create a new record" do expect { - post :create, :tweet => { :content => "Hello World!" } - }.to change { Tweet.count }.by(1) + post :create, :twet => { :content => "Hello World!" } + }.to change { Twet.count }.by(1) end end end diff --git a/spec/factories/tweets.rb b/spec/factories/twets.rb similarity index 90% rename from spec/factories/tweets.rb rename to spec/factories/twets.rb index 5021e33..2cf6cd1 100644 --- a/spec/factories/tweets.rb +++ b/spec/factories/twets.rb @@ -1,7 +1,7 @@ # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :tweet do + factory :twet do user { FactoryGirl.create(:user) } content { Faker::Lorem.sentence(3) } end diff --git a/spec/helpers/tweets_helper_spec.rb b/spec/helpers/twets_helper_spec.rb similarity index 75% rename from spec/helpers/tweets_helper_spec.rb rename to spec/helpers/twets_helper_spec.rb index 4764c12..49912e2 100644 --- a/spec/helpers/tweets_helper_spec.rb +++ b/spec/helpers/twets_helper_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' # Specs in this file have access to a helper object that includes -# the TweetsHelper. For example: +# the TwetsHelper. For example: # -# describe TweetsHelper do +# describe TwetsHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") # end # end # end -describe TweetsHelper do +describe TwetsHelper do end diff --git a/spec/models/tweet_spec.rb b/spec/models/twet_spec.rb similarity index 55% rename from spec/models/tweet_spec.rb rename to spec/models/twet_spec.rb index 33828f5..347ad19 100644 --- a/spec/models/tweet_spec.rb +++ b/spec/models/twet_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe Tweet do +describe Twet do context "associations" do it { should belong_to :user } end context "factories" do - describe "#tweet" do - subject { FactoryGirl.build(:tweet) } + describe "#twet" do + subject { FactoryGirl.build(:twet) } it { should be_valid } end @@ -16,11 +16,11 @@ context "validations" do it { should validate_presence_of :content } it "should not be valid when the length is between 2 and 140 characters" do - t1 = Tweet.new(:content => '1') - t2 = Tweet.new(:content => ':)') - t3 = Tweet.new(:content => 'fdsjklsjfksdk fd kslfsdjkd') - t4 = Tweet.new(:content => '*'*140) - t5 = Tweet.new(:content => '#'*141) + t1 = Twet.new(:content => '1') + t2 = Twet.new(:content => ':)') + t3 = Twet.new(:content => 'fdsjklsjfksdk fd kslfsdjkd') + t4 = Twet.new(:content => '*'*140) + t5 = Twet.new(:content => '#'*141) [t1, t5].each do |t| t.valid? @@ -37,12 +37,12 @@ end describe ".by_user_ids" do - let!(:t1) { FactoryGirl.create(:tweet) } - let!(:t2) { FactoryGirl.create(:tweet)} - let!(:t3) { FactoryGirl.create(:tweet) } + let!(:t1) { FactoryGirl.create(:twet) } + let!(:t2) { FactoryGirl.create(:twet)} + let!(:t3) { FactoryGirl.create(:twet) } it "should search by user ids" do - Tweet.by_user_ids(t1.user.id, t3.user.id).load.map(&:user_id).should == [t3.user.id, t1.user.id] + Twet.by_user_ids(t1.user.id, t3.user.id).load.map(&:user_id).should == [t3.user.id, t1.user.id] end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2c9b0f6..6353506 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,7 +3,7 @@ describe User do context "associations" do it { should have_many :follows } - it { should have_many :tweets } + it { should have_many :twets } end context "factories" do @@ -38,11 +38,11 @@ end end - describe "#all_tweets" do + describe "#all_twets" do let!(:user) { FactoryGirl.create(:user) } - let(:t1) { FactoryGirl.create(:tweet, :user => user)} - let(:t2) { FactoryGirl.create(:tweet) } - let(:t3) { FactoryGirl.create(:tweet) } + let(:t1) { FactoryGirl.create(:twet, :user => user)} + let(:t2) { FactoryGirl.create(:twet) } + let(:t3) { FactoryGirl.create(:twet) } before do t1 @@ -50,8 +50,8 @@ t3 end - it "should return all my tweets and followed tweets, ordered by creation time" do - user.all_tweets.load.map(&:id).should == [t2.id, t1.id] + it "should return all my twets and followed twets, ordered by creation time" do + user.all_twets.load.map(&:id).should == [t2.id, t1.id] end end end