will_paginate 3.1.8 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -5
  3. data/lib/will_paginate/active_record.rb +3 -3
  4. data/lib/will_paginate/i18n.rb +3 -3
  5. data/lib/will_paginate/locale/en.yml +4 -0
  6. data/lib/will_paginate/mongoid.rb +2 -0
  7. data/lib/will_paginate/page_number.rb +7 -11
  8. data/lib/will_paginate/railtie.rb +3 -4
  9. data/lib/will_paginate/version.rb +3 -3
  10. data/lib/will_paginate/view_helpers/action_view.rb +8 -4
  11. data/lib/will_paginate/view_helpers/hanami.rb +41 -0
  12. data/lib/will_paginate/view_helpers/link_renderer.rb +14 -8
  13. data/lib/will_paginate.rb +0 -12
  14. metadata +17 -48
  15. data/lib/will_paginate/data_mapper.rb +0 -100
  16. data/lib/will_paginate/view_helpers/merb.rb +0 -26
  17. data/spec/collection_spec.rb +0 -139
  18. data/spec/console +0 -12
  19. data/spec/console_fixtures.rb +0 -28
  20. data/spec/database.yml +0 -29
  21. data/spec/fake_rubygems.rb +0 -18
  22. data/spec/finders/active_record_spec.rb +0 -417
  23. data/spec/finders/activerecord_test_connector.rb +0 -140
  24. data/spec/finders/data_mapper_spec.rb +0 -114
  25. data/spec/finders/data_mapper_test_connector.rb +0 -54
  26. data/spec/finders/mongoid_spec.rb +0 -145
  27. data/spec/finders/sequel_spec.rb +0 -65
  28. data/spec/finders/sequel_test_connector.rb +0 -15
  29. data/spec/fixtures/admin.rb +0 -3
  30. data/spec/fixtures/developer.rb +0 -9
  31. data/spec/fixtures/developers_projects.yml +0 -13
  32. data/spec/fixtures/project.rb +0 -13
  33. data/spec/fixtures/projects.yml +0 -6
  34. data/spec/fixtures/replies.yml +0 -29
  35. data/spec/fixtures/reply.rb +0 -8
  36. data/spec/fixtures/schema.rb +0 -38
  37. data/spec/fixtures/topic.rb +0 -8
  38. data/spec/fixtures/topics.yml +0 -30
  39. data/spec/fixtures/user.rb +0 -2
  40. data/spec/fixtures/users.yml +0 -35
  41. data/spec/matchers/deprecation_matcher.rb +0 -27
  42. data/spec/matchers/phrase_matcher.rb +0 -19
  43. data/spec/matchers/query_count_matcher.rb +0 -36
  44. data/spec/page_number_spec.rb +0 -83
  45. data/spec/per_page_spec.rb +0 -41
  46. data/spec/spec_helper.rb +0 -46
  47. data/spec/view_helpers/action_view_spec.rb +0 -468
  48. data/spec/view_helpers/base_spec.rb +0 -143
  49. data/spec/view_helpers/link_renderer_base_spec.rb +0 -87
  50. data/spec/view_helpers/view_example_group.rb +0 -146
@@ -1,140 +0,0 @@
1
- require 'active_record'
2
- require 'active_record/fixtures'
3
- require 'active_support/multibyte' # needed for Ruby 1.9.1
4
- require 'stringio'
5
- require 'erb'
6
-
7
- # https://travis-ci.org/mislav/will_paginate/jobs/99999001
8
- require 'active_support/core_ext/string/conversions'
9
- class String
10
- alias to_datetime_without_patch to_datetime
11
- def to_datetime
12
- to_datetime_without_patch
13
- rescue ArgumentError
14
- return nil
15
- end
16
- end
17
-
18
- $query_count = 0
19
- $query_sql = []
20
-
21
- ignore_sql = /
22
- ^(
23
- PRAGMA | SHOW\ (max_identifier_length|search_path) |
24
- SELECT\ (currval|CAST|@@IDENTITY|@@ROWCOUNT) |
25
- SHOW\ ((FULL\ )?FIELDS|TABLES)
26
- )\b |
27
- \bFROM\ (sqlite_master|pg_tables|pg_attribute)\b
28
- /x
29
-
30
- ActiveSupport::Notifications.subscribe(/^sql\./) do |*args|
31
- payload = args.last
32
- unless payload[:name] =~ /^Fixture/ or payload[:sql] =~ ignore_sql
33
- $query_count += 1
34
- $query_sql << payload[:sql]
35
- end
36
- end
37
-
38
- module ActiverecordTestConnector
39
- extend self
40
-
41
- attr_accessor :connected
42
-
43
- FIXTURES_PATH = File.expand_path('../../fixtures', __FILE__)
44
-
45
- Fixtures = defined?(ActiveRecord::FixtureSet) ? ActiveRecord::FixtureSet :
46
- defined?(ActiveRecord::Fixtures) ? ActiveRecord::Fixtures :
47
- ::Fixtures
48
-
49
- # Set our defaults
50
- self.connected = false
51
-
52
- def setup
53
- unless self.connected
54
- setup_connection
55
- load_schema
56
- add_load_path FIXTURES_PATH
57
- self.connected = true
58
- end
59
- end
60
-
61
- private
62
-
63
- def add_load_path(path)
64
- dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
65
- dep.autoload_paths.unshift path
66
- end
67
-
68
- def setup_connection
69
- db = ENV['DB'].blank?? 'sqlite3' : ENV['DB']
70
-
71
- erb = ERB.new(File.read(File.expand_path('../../database.yml', __FILE__)))
72
- configurations = YAML.load(erb.result)
73
- raise "no configuration for '#{db}'" unless configurations.key? db
74
- configuration = configurations[db]
75
-
76
- # ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'
77
- puts "using #{configuration['adapter']} adapter"
78
-
79
- ActiveRecord::Base.configurations = { db => configuration }
80
- ActiveRecord::Base.establish_connection(db.to_sym)
81
- ActiveRecord::Base.default_timezone = :utc
82
-
83
- case configuration['adapter']
84
- when 'mysql'
85
- fix_primary_key(ActiveRecord::ConnectionAdapters::MysqlAdapter)
86
- when 'mysql2'
87
- fix_primary_key(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
88
- end
89
- end
90
-
91
- def load_schema
92
- begin
93
- $stdout = StringIO.new
94
- ActiveRecord::Migration.verbose = false
95
- load File.join(FIXTURES_PATH, 'schema.rb')
96
- ensure
97
- $stdout = STDOUT
98
- end
99
- end
100
-
101
- def fix_primary_key(adapter_class)
102
- if ActiveRecord::VERSION::STRING < "4.1"
103
- adapter_class::NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
104
- end
105
- end
106
-
107
- module FixtureSetup
108
- def fixtures(*tables)
109
- table_names = tables.map { |t| t.to_s }
110
-
111
- fixtures = Fixtures.create_fixtures ActiverecordTestConnector::FIXTURES_PATH, table_names
112
- @@loaded_fixtures = {}
113
- @@fixture_cache = {}
114
-
115
- unless fixtures.nil?
116
- if fixtures.instance_of?(Fixtures)
117
- @@loaded_fixtures[fixtures.table_name] = fixtures
118
- else
119
- fixtures.each { |f| @@loaded_fixtures[f.table_name] = f }
120
- end
121
- end
122
-
123
- table_names.each do |table_name|
124
- define_method(table_name) do |*fixtures|
125
- @@fixture_cache[table_name] ||= {}
126
-
127
- instances = fixtures.map do |fixture|
128
- if @@loaded_fixtures[table_name][fixture.to_s]
129
- @@fixture_cache[table_name][fixture] ||= @@loaded_fixtures[table_name][fixture.to_s].find
130
- else
131
- raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
132
- end
133
- end
134
-
135
- instances.size == 1 ? instances.first : instances
136
- end
137
- end
138
- end
139
- end
140
- end
@@ -1,114 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if !ENV['SKIP_NONRAILS_TESTS']
4
- require 'will_paginate/data_mapper'
5
- require File.expand_path('../data_mapper_test_connector', __FILE__)
6
- datamapper_loaded = true
7
- else
8
- datamapper_loaded = false
9
- end
10
-
11
- describe WillPaginate::DataMapper do
12
-
13
- it "has per_page" do
14
- Animal.per_page.should == 30
15
- begin
16
- Animal.per_page = 10
17
- Animal.per_page.should == 10
18
-
19
- subclass = Class.new(Animal)
20
- subclass.per_page.should == 10
21
- ensure
22
- Animal.per_page = 30
23
- end
24
- end
25
-
26
- it "doesn't make normal collections appear paginated" do
27
- Animal.all.should_not be_paginated
28
- end
29
-
30
- it "paginates to first page by default" do
31
- animals = Animal.paginate(:page => nil)
32
-
33
- animals.should be_paginated
34
- animals.current_page.should == 1
35
- animals.per_page.should == 30
36
- animals.offset.should == 0
37
- animals.total_entries.should == 3
38
- animals.total_pages.should == 1
39
- end
40
-
41
- it "paginates to first page, explicit limit" do
42
- animals = Animal.paginate(:page => 1, :per_page => 2)
43
-
44
- animals.current_page.should == 1
45
- animals.per_page.should == 2
46
- animals.total_entries.should == 3
47
- animals.total_pages.should == 2
48
- animals.map {|a| a.name }.should == %w[ Dog Cat ]
49
- end
50
-
51
- it "paginates to second page" do
52
- animals = Animal.paginate(:page => 2, :per_page => 2)
53
-
54
- animals.current_page.should == 2
55
- animals.offset.should == 2
56
- animals.map {|a| a.name }.should == %w[ Lion ]
57
- end
58
-
59
- it "paginates a collection" do
60
- friends = Animal.all(:notes.like => '%friend%')
61
- friends.paginate(:page => 1).per_page.should == 30
62
- friends.paginate(:page => 1, :per_page => 1).total_entries.should == 2
63
- end
64
-
65
- it "paginates a limited collection" do
66
- animals = Animal.all(:limit => 2).paginate(:page => 1)
67
- animals.per_page.should == 2
68
- end
69
-
70
- it "has page() method" do
71
- Animal.page(2).per_page.should == 30
72
- Animal.page(2).offset.should == 30
73
- Animal.page(2).current_page.should == 2
74
- Animal.all(:limit => 2).page(2).per_page.should == 2
75
- end
76
-
77
- it "has total_pages at 1 for empty collections" do
78
- Animal.all(:conditions => ['1=2']).page(1).total_pages.should == 1
79
- end
80
-
81
- it "overrides total_entries count with a fixed value" do
82
- lambda {
83
- animals = Animal.paginate :page => 1, :per_page => 3, :total_entries => 999
84
- animals.total_entries.should == 999
85
- }.should run_queries(0)
86
- end
87
-
88
- it "supports a non-int for total_entries" do
89
- topics = Animal.paginate :page => 1, :per_page => 3, :total_entries => "999"
90
- topics.total_entries.should == 999
91
- end
92
-
93
-
94
- it "can iterate and then call WP methods" do
95
- animals = Animal.all(:limit => 2).page(1)
96
- animals.each { |a| }
97
- animals.total_entries.should == 3
98
- end
99
-
100
- it "augments to_a to return a WP::Collection" do
101
- animals = Animal.all(:limit => 2).page(1)
102
- array = animals.to_a
103
- array.size.should == 2
104
- array.should be_kind_of(WillPaginate::Collection)
105
- array.current_page.should == 1
106
- array.per_page.should == 2
107
- end
108
-
109
- it "doesn't have a problem assigning has-one-through relationship" do
110
- human = Human.create :name => "Mislav"
111
- human.pet = Animal.first
112
- end
113
-
114
- end if datamapper_loaded
@@ -1,54 +0,0 @@
1
- require 'sqlite3'
2
- require 'dm-core'
3
- require 'dm-core/support/logger'
4
- require 'dm-migrations'
5
-
6
- DataMapper.setup :default, 'sqlite3::memory:'
7
-
8
- # Define models
9
- class Animal
10
- include DataMapper::Resource
11
- property :id, Serial
12
- property :name, String
13
- property :notes, Text
14
-
15
- def self.setup
16
- Animal.create(:name => 'Dog', :notes => "Man's best friend")
17
- Animal.create(:name => 'Cat', :notes => "Woman's best friend")
18
- Animal.create(:name => 'Lion', :notes => 'King of the Jungle')
19
- end
20
- end
21
-
22
- class Ownership
23
- include DataMapper::Resource
24
-
25
- belongs_to :animal, :key => true
26
- belongs_to :human, :key => true
27
-
28
- def self.setup
29
- end
30
- end
31
-
32
- class Human
33
- include DataMapper::Resource
34
-
35
- property :id, Serial
36
- property :name, String
37
-
38
- has n, :ownerships
39
- has 1, :pet, :model => 'Animal', :through => :ownerships, :via => :animal
40
-
41
- def self.setup
42
- end
43
- end
44
-
45
- # Load fixtures
46
- [Animal, Ownership, Human].each do |klass|
47
- klass.auto_migrate!
48
- klass.setup
49
- end
50
-
51
- if 'irb' == $0
52
- DataMapper.logger.set_log($stdout, :debug)
53
- DataMapper.logger.auto_flush = true
54
- end
@@ -1,145 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if !ENV['SKIP_NONRAILS_TESTS']
4
- if defined?(Rails)
5
- old_rails = Rails
6
- # Mongoid sees the `Rails` constant and then proceeds to `require "rails"`
7
- # from its railtie. This tricks it into believing there is no Rails.
8
- Object.send(:remove_const, :Rails)
9
- end
10
- require 'will_paginate/mongoid'
11
- Object.send(:const_set, :Rails, old_rails) if old_rails
12
-
13
- Mongoid.connect_to 'will_paginate_test'
14
- class MongoidModel
15
- include Mongoid::Document
16
- end
17
-
18
- mongoid_loaded = true
19
- else
20
- mongoid_loaded = false
21
- end
22
-
23
- describe WillPaginate::Mongoid do
24
- before(:all) do
25
- MongoidModel.delete_all
26
- 4.times { MongoidModel.create! }
27
- end
28
-
29
- let(:criteria) { MongoidModel.criteria }
30
-
31
- describe "#page" do
32
- it "should forward to the paginate method" do
33
- criteria.expects(:paginate).with(:page => 2).returns("itself")
34
- criteria.page(2).should == "itself"
35
- end
36
-
37
- it "should not override per_page if set earlier in the chain" do
38
- criteria.paginate(:per_page => 10).page(1).per_page.should == 10
39
- criteria.paginate(:per_page => 20).page(1).per_page.should == 20
40
- end
41
- end
42
-
43
- describe "#per_page" do
44
- it "should set the limit if given an argument" do
45
- criteria.per_page(10).options[:limit].should == 10
46
- end
47
-
48
- it "should return the current limit if no argument is given" do
49
- criteria.per_page.should == nil
50
- criteria.per_page(10).per_page.should == 10
51
- end
52
-
53
- it "should be interchangable with limit" do
54
- criteria.limit(15).per_page.should == 15
55
- end
56
-
57
- it "should be nil'able" do
58
- criteria.per_page(nil).per_page.should be_nil
59
- end
60
- end
61
-
62
- describe "#paginate" do
63
- it "should use criteria" do
64
- criteria.paginate.should be_instance_of(::Mongoid::Criteria)
65
- end
66
-
67
- it "should not override page number if set earlier in the chain" do
68
- criteria.page(3).paginate.current_page.should == 3
69
- end
70
-
71
- it "should limit according to per_page parameter" do
72
- criteria.paginate(:per_page => 10).options.should include(:limit => 10)
73
- end
74
-
75
- it "should skip according to page and per_page parameters" do
76
- criteria.paginate(:page => 2, :per_page => 5).options.should include(:skip => 5)
77
- end
78
-
79
- specify "first fallback value for per_page option is the current limit" do
80
- criteria.limit(12).paginate.options.should include(:limit => 12)
81
- end
82
-
83
- specify "second fallback value for per_page option is WillPaginate.per_page" do
84
- criteria.paginate.options.should include(:limit => WillPaginate.per_page)
85
- end
86
-
87
- specify "page should default to 1" do
88
- criteria.paginate.options.should include(:skip => 0)
89
- end
90
-
91
- it "should convert strings to integers" do
92
- criteria.paginate(:page => "2", :per_page => "3").options.should include(:limit => 3)
93
- end
94
-
95
- describe "collection compatibility" do
96
- describe "#total_count" do
97
- it "should be calculated correctly" do
98
- criteria.paginate(:per_page => 1).total_entries.should == 4
99
- criteria.paginate(:per_page => 3).total_entries.should == 4
100
- end
101
-
102
- it "should be cached" do
103
- criteria.expects(:count).once.returns(123)
104
- criteria.paginate
105
- 2.times { criteria.total_entries.should == 123 }
106
- end
107
- end
108
-
109
- it "should calculate total_pages" do
110
- criteria.paginate(:per_page => 1).total_pages.should == 4
111
- criteria.paginate(:per_page => 3).total_pages.should == 2
112
- criteria.paginate(:per_page => 10).total_pages.should == 1
113
- end
114
-
115
- it "should return per_page" do
116
- criteria.paginate(:per_page => 1).per_page.should == 1
117
- criteria.paginate(:per_page => 5).per_page.should == 5
118
- end
119
-
120
- describe "#current_page" do
121
- it "should return current_page" do
122
- criteria.paginate(:page => 1).current_page.should == 1
123
- criteria.paginate(:page => 3).current_page.should == 3
124
- end
125
-
126
- it "should be casted to PageNumber" do
127
- page = criteria.paginate(:page => 1).current_page
128
- (page.instance_of? WillPaginate::PageNumber).should be
129
- end
130
- end
131
-
132
- it "should return offset" do
133
- criteria.paginate(:page => 1).offset.should == 0
134
- criteria.paginate(:page => 2, :per_page => 5).offset.should == 5
135
- criteria.paginate(:page => 3, :per_page => 10).offset.should == 20
136
- end
137
-
138
- it "should not pollute plain mongoid criterias" do
139
- %w(total_entries total_pages current_page).each do |method|
140
- criteria.should_not respond_to(method)
141
- end
142
- end
143
- end
144
- end
145
- end if mongoid_loaded
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if !ENV['SKIP_NONRAILS_TESTS']
4
- require 'will_paginate/sequel'
5
- require File.expand_path('../sequel_test_connector', __FILE__)
6
- sequel_loaded = true
7
- else
8
- sequel_loaded = false
9
- end
10
-
11
- describe Sequel::Dataset::Pagination, 'extension' do
12
-
13
- class Car < Sequel::Model
14
- end
15
-
16
- it "should have the #paginate method" do
17
- Car.should respond_to(:paginate)
18
- end
19
-
20
- it "should NOT have the #paginate_by_sql method" do
21
- Car.should_not respond_to(:paginate_by_sql)
22
- end
23
-
24
- describe 'pagination' do
25
- before(:all) do
26
- Car.create(:name => 'Shelby', :notes => "Man's best friend")
27
- Car.create(:name => 'Aston Martin', :notes => "Woman's best friend")
28
- Car.create(:name => 'Corvette', :notes => 'King of the Jungle')
29
- end
30
-
31
- it "should imitate WillPaginate::Collection" do
32
- result = Car.paginate(1, 2)
33
-
34
- result.should_not be_empty
35
- result.size.should == 2
36
- result.length.should == 2
37
- result.total_entries.should == 3
38
- result.total_pages.should == 2
39
- result.per_page.should == 2
40
- result.current_page.should == 1
41
- end
42
-
43
- it "should perform" do
44
- Car.paginate(1, 2).all.should == [Car[1], Car[2]]
45
- end
46
-
47
- it "should be empty" do
48
- result = Car.paginate(3, 2)
49
- result.should be_empty
50
- end
51
-
52
- it "should perform with #select and #order" do
53
- result = Car.select("name as foo".lit).order(:name).paginate(1, 2).all
54
- result.size.should == 2
55
- result.first.values[:foo].should == "Aston Martin"
56
- end
57
-
58
- it "should perform with #filter" do
59
- results = Car.filter(:name => 'Shelby').paginate(1, 2).all
60
- results.size.should == 1
61
- results.first.should == Car.find(:name => 'Shelby')
62
- end
63
- end
64
-
65
- end if sequel_loaded
@@ -1,15 +0,0 @@
1
- require 'sequel'
2
-
3
- Symbol.class_eval do
4
- # Active Record calculations tries `as` on some objects but chokes when that
5
- # object was a Symbol and it gets a Sequel::SQL::AliasedExpression.
6
- undef as if method_defined? :as
7
- end
8
-
9
- db = Sequel.sqlite
10
-
11
- db.create_table :cars do
12
- primary_key :id, :integer, :auto_increment => true
13
- column :name, :text
14
- column :notes, :text
15
- end
@@ -1,3 +0,0 @@
1
- class Admin < User
2
- has_many :companies
3
- end
@@ -1,9 +0,0 @@
1
- class Developer < User
2
- has_and_belongs_to_many :projects, :join_table => 'developers_projects'
3
-
4
- scope :poor, lambda {
5
- where(['salary <= ?', 80000]).order('salary')
6
- }
7
-
8
- def self.per_page() 10 end
9
- end
@@ -1,13 +0,0 @@
1
- david_action_controller:
2
- developer_id: 1
3
- project_id: 2
4
- joined_on: 2004-10-10
5
-
6
- david_active_record:
7
- developer_id: 1
8
- project_id: 1
9
- joined_on: 2004-10-10
10
-
11
- jamis_active_record:
12
- developer_id: 2
13
- project_id: 1
@@ -1,13 +0,0 @@
1
- class Project < ActiveRecord::Base
2
- has_and_belongs_to_many :developers, :join_table => 'developers_projects'
3
-
4
- has_many :topics
5
- # :finder_sql => 'SELECT * FROM topics WHERE (topics.project_id = #{id})',
6
- # :counter_sql => 'SELECT COUNT(*) FROM topics WHERE (topics.project_id = #{id})'
7
-
8
- has_many :replies, :through => :topics do
9
- def only_recent(params = {})
10
- where(['replies.created_at > ?', 15.minutes.ago])
11
- end
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- active_record:
2
- id: 1
3
- name: Active Record
4
- action_controller:
5
- id: 2
6
- name: Action Controller
@@ -1,29 +0,0 @@
1
- witty_retort:
2
- id: 1
3
- topic_id: 1
4
- content: Birdman is better!
5
- created_at: <%= 6.hours.ago.utc.to_s(:db) %>
6
-
7
- another:
8
- id: 2
9
- topic_id: 2
10
- content: Nuh uh!
11
- created_at: <%= 1.hour.ago.utc.to_s(:db) %>
12
-
13
- spam:
14
- id: 3
15
- topic_id: 1
16
- content: Nice site!
17
- created_at: <%= 1.hour.ago.utc.to_s(:db) %>
18
-
19
- decisive:
20
- id: 4
21
- topic_id: 4
22
- content: "I'm getting to the bottom of this"
23
- created_at: <%= 30.minutes.ago.utc.to_s(:db) %>
24
-
25
- brave:
26
- id: 5
27
- topic_id: 4
28
- content: "AR doesn't scare me a bit"
29
- created_at: <%= 10.minutes.ago.utc.to_s(:db) %>
@@ -1,8 +0,0 @@
1
- class Reply < ActiveRecord::Base
2
- scope :recent, lambda {
3
- where(['replies.created_at > ?', 15.minutes.ago]).
4
- order('replies.created_at DESC')
5
- }
6
-
7
- validates_presence_of :content
8
- end
@@ -1,38 +0,0 @@
1
- ActiveRecord::Schema.define do
2
-
3
- create_table "users", :force => true do |t|
4
- t.column "name", :text
5
- t.column "salary", :integer, :default => 70000
6
- t.column "created_at", :datetime
7
- t.column "updated_at", :datetime
8
- t.column "type", :text
9
- end
10
-
11
- create_table "projects", :force => true do |t|
12
- t.column "name", :text
13
- end
14
-
15
- create_table "developers_projects", :id => false, :force => true do |t|
16
- t.column "developer_id", :integer, :null => false
17
- t.column "project_id", :integer, :null => false
18
- t.column "joined_on", :date
19
- t.column "access_level", :integer, :default => 1
20
- end
21
-
22
- create_table "topics", :force => true do |t|
23
- t.column "project_id", :integer
24
- t.column "title", :string
25
- t.column "subtitle", :string
26
- t.column "content", :text
27
- t.column "created_at", :datetime
28
- t.column "updated_at", :datetime
29
- end
30
-
31
- create_table "replies", :force => true do |t|
32
- t.column "content", :text
33
- t.column "created_at", :datetime
34
- t.column "updated_at", :datetime
35
- t.column "topic_id", :integer
36
- end
37
-
38
- end
@@ -1,8 +0,0 @@
1
- class Topic < ActiveRecord::Base
2
- has_many :replies, :dependent => :destroy
3
- belongs_to :project
4
-
5
- scope :mentions_activerecord, lambda {
6
- where(['topics.title LIKE ?', '%ActiveRecord%'])
7
- }
8
- end