Commit Graph

1606 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
973b278598 Remove app building setup/teardown for remote ip railtie tests
These tests rely on "make_basic_app", which is a faster version that
does not need to create the whole app directory structure.
2012-08-21 17:37:52 -03:00
Carlos Antonio da Silva
b85894e854 Set eager load option in "make_basic_app" for railties tests
Avoid output with config option not set when running some tests.
2012-08-21 17:36:00 -03:00
José Valim
5d416b9078 Deprecate config.threadsafe! 2012-08-21 14:47:43 -03:00
José Valim
2801786e1a Get rid of config.preload_frameworks in favor of config.eager_load_namespaces
The new option allows any Ruby namespace to be registered and set
up for eager load. We are effectively exposing the structure existing
in Rails since v3.0 for all developers in order to make their applications
thread-safe and CoW friendly.
2012-08-21 14:47:19 -03:00
José Valim
11bc3487ab Remove allow_concurrency as a flag
The flag was mainly used to add a Rack::Lock middleware to
the stack, but the only scenario the lock is desired is in
development.

If you are deploying on a not-threaded server, the Rack::Lock
does not provide any benefit since you don't have concurrent
accesses. On the other hand, if you are on a threaded server,
you don't want the lock, since it defeats the purpose of using
a threaded server.

If there is someone out there, running on a thread server
and does want a lock, it can be added to your environment
as easy as: `use Rack::Lock`
2012-08-21 14:46:12 -03:00
José Valim
e6747d87f3 Allow users to choose when to eager_load the application or not.
Previously, the eager load behavior was mostly coupled to
config.cache_classes, however this was suboptimal since in
some environments a developer may want to cache classes but
not necessarily load them all on boot (for example, test env).

This pull request also promotes the use of config.eager_load
set to true by default in production. In the majority of the
cases, this is the behavior you want since it will copy most
of your app into memory on boot (which was also the previous
behavior).

Finally, this fix a long standing Rails bug where it was
impossible to access a model in a rake task when Rails was
set as thread safe.
2012-08-21 14:46:12 -03:00
Piotr Sarnacki
5b3bb61f3f Fix handling SCRIPT_NAME from within mounted engine's
When you mount your application at a path, for example /myapp, server
should set SCRIPT_NAME to /myapp. With such information, rails
application knows that it's mounted at /myapp path and it should generate
routes relative to that path.

Before this patch, rails handled SCRIPT_NAME correctly only for regular
apps, but it failed to do it for mounted engines. The solution was to
hardcode default_url_options[:script_name], which is not the best answer
- it will work only when application is mounted at a fixed path.

This patch fixes the situation by respecting original value of
SCRIPT_NAME when generating application's routes from engine and the
other way round - when you generate engine's routes from application.

This is done by using one of 2 pieces of information in env - current
SCRIPT_NAME or SCRIPT_NAME for a corresponding router. This is because
we have 2 cases to handle:

- generating engine's route from application: in this situation
  SCRIPT_NAME is basically SCRIPT_NAME set by the server and it
  indicates the place where application is mounted, so we can just pass
  it as :original_script_name in url_options. :original_script_name is
  used because if we use :script_name, router will ignore generating
  prefix for engine

- generating application's route from engine: in this situation we
  already lost information about the SCRIPT_NAME that server used. For
  example if application is mounted at /myapp and engine is mounted at
  /blog, at this point SCRIPT_NAME is equal /myapp/blog. Because of that
  we need to keep reference to /myapp SCRIPT_NAME by binding it to the
  current router. Later on we can extract it and use when generating url

Please note that starting from now you *should not* use
default_url_options[:script_name] explicitly if your server already
passes correct SCRIPT_NAME to rack env.

(closes #6933)
2012-08-11 00:21:46 +02:00
Jon Leighton
09d2671cb6 remove some artifacts of dependent_restrict_raises that I missed 2012-08-10 18:12:26 +01:00
Jon Leighton
5ad79989ef Remove the dependent_restrict_raises option.
It's not really a good idea to have this as a global config option. We
should allow people to specify the behaviour per association.

There will now be two new values:

* :dependent => :restrict_with_exception implements the current
  behaviour of :restrict. :restrict itself is deprecated in favour of
  :restrict_with_exception.
* :dependent => :restrict_with_error implements the new behaviour - it
  adds an error to the owner if there are dependent records present

See #4727 for the original discussion of this.
2012-08-10 17:45:06 +01:00
Aaron Patterson
481dac9ec0 make assertions easier to track down 2012-08-07 10:54:47 -07:00
David Heinemeier Hansson
fb883318c8 Revert "The application generator generates public/humans.txt with some basic data". I dont consider this something most people is going to want most of the time. If you want to add it in your own app, knock yourself out. But it doesnt belong in Rails imo 2012-08-07 11:18:00 -05:00
Rafael Mendonça França
d87524773d Fix tests.
Since b6ab4417720e03f1551abda2f1e4bd0a392dd04e the single quotes are
being escaped in the templates.
2012-08-02 16:04:49 -03:00
Santiago Pastorino
449039a86d Remove ActionDispatch::Head middleware in favor of Rack::Head
Closes #7110 there's more work to do on rack-cache issue 69
2012-07-23 14:34:13 -03:00
Aaron Patterson
3b3ca13307 adding Rails::Queueing::Container
This allows us to do:

In your configuration:
Rails.queue[:image_queue] = SomeQueue.new
Rails.queue[:mail_queue]  = SomeQueue.new

In your app code:
Rails.queue[:mail_queue].push MailJob.new

Both jobs pushed to the same default queue
Rails.queue.push DefaultJob.new
Rails.queue[:default].push DefaultJob.new
2012-07-19 12:09:39 -07:00
Aleksey Magusev
5a7d31913b Add fkey attributes to join_table migration generator 2012-07-19 00:24:21 +04:00
José Valim
58ccc9f6c5 Merge pull request #7028 from lexmag/join_table_indexes
Add indexes to create_join_table method
2012-07-18 00:16:39 -07:00
Aleksey Magusev
211d88b71b Add join table migration generator
For instance, running

    rails g migration CreateMediaJoinTable artists musics:uniq

will create a migration with

    create_join_table :artists, :musics do |t|
      # t.index [:artist_id, :music_id]
      t.index [:music_id, :artist_id], unique: true
    end
2012-07-18 00:13:19 +04:00
kennyj
414008f98e Fix class_eval without __FILE__ and __LINE__. 2012-07-18 01:16:55 +09:00
Rafael Mendonça França
bbc08c759c Merge pull request #6956 from lexmag/ref_migration_generator
Add references statements to migration generator
2012-07-08 12:12:15 -07:00
Aleksey Magusev
0cae7c60ac Add references statements to migration generator
AddXXXToYYY/RemoveXXXFromYYY migrations are produced with references
statements, for instance

    rails g migration AddReferencesToProducts user:references
supplier:references{polymorphic}

will generate the migration with:

    add_reference :products, :user, index: true
    add_reference :products, :supplier, polymorphic: true, index: true
2012-07-08 23:03:05 +04:00
Carlos Antonio da Silva
21c5bc9260 Remove RoutesInspector from railties, since it was moved to AP
Changes introduced in 7404cda9f61e41d52ce244d60abbf598684a96c4.
Fix railties build.
2012-07-08 13:20:24 -03:00
Wojciech Wnętrzak
8fe9b43b30 Fixed generating namespaced table_name_prefix in engines 2012-07-06 21:22:53 +02:00
Wojciech Wnętrzak
f874b15561 Added failing test for generating namespaced table_name_prefix in engines 2012-07-06 21:22:14 +02:00
Aaron Patterson
b7a4fe18f2 remove duplicate requires of mocha.
Mocha is already required by AS::TestCase, so remove the duplicate
requires.
2012-07-03 14:28:29 -07:00
Francesco Rodriguez
1c5722cdf6 remove test/dummy from gitignore when "plugin new -T" 2012-07-03 11:58:17 -05:00
Paul Battley
b44104ae13 Make TestQueueTest work with marshalling queue
This requires all jobs to be instances of named classes, without block
implementations of methods.
2012-07-03 13:03:48 +01:00
Paul Battley
a3ade2e99c Ensure jobs do not refer to the queue
Jobs pushed to the queue should not contain a reference to it. As the queue
itself cannot be marshalled, and as a consequence of checking the
marshallability of all jobs in the test environment, we can now guarantee this
to be the case in the test environment when using the default TestQueue
implementation.
2012-07-03 12:01:53 +01:00
Paul Battley
33113ba0e7 Ensure test jobs are marshallable
By marshalling and unmarshalling jobs when adding them to the test queue, we
can ensure that jobs created during test runs are valid candidates for
marshalling, and, thus, that they can be used with queueing backends other than
the default simple in-process implementation.

This will also be used in a subsequent commit to ensure that jobs pushed to the
queue do not contain a reference to the queue itself.
2012-07-03 12:01:53 +01:00
Paul Battley
8e1d8fd093 Track queue threading with named classes
Using an anonymous class prevented marshalling: we're not doing that yet, but
the next commit will introduce this. This also provided an opportunity to
improve the expressivity of the tests and to make the assertion failure
messages clearer.
2012-07-03 12:01:53 +01:00
Rahul P. Chaudhari
40262ab88f Made file name and class name consistant 2012-07-02 11:40:27 +05:30
Carlos Antonio da Silva
83302a4c13 Fix failing test related to persist glob when replacing a path
Introduced in pull request #6910, merged in 2ee3fa1a48513a2c42833e2e1f60fe03769bc295
2012-07-01 13:56:11 -03:00
José Valim
2ee3fa1a48 Merge pull request #6910 from mulder/fix_path_glob
Persist glob when replacing a path
2012-07-01 02:54:33 -07:00
Nicholas Mulder
0f4d005501 Persist glob when replacing a path
When Rails::Paths::Root's []= is used to replace a path it should persist the previous path's glob. Without passing the glob along we get gnarly bugs when trying to wire up things like engines.

    module FooEngine
      class Engine < ::Rails::Engine
        isolate_namespace FooEngine

        config.paths['config/initializers'] = "lib/foo_engine/initializers"
      end
    end

    ## Example of behaviour before this commit.
    #
    # Before the initializer override:
    >> FooEngine::Engine.config.paths["config/initializers"].glob
    => "**/*.rb"

    # After the initializer override:
    >> FooEngine::Engine.config.paths["config/initializers"].glob
    => nil

    ## Example of behaviour after this commit.
    #
    # Before the initializer override:
    >> FooEngine::Engine.config.paths["config/initializers"].glob
    => "**/*.rb"

    # After the initializer override:
    >> FooEngine::Engine.config.paths["config/initializers"].glob
    => "**/*.rb"
2012-06-30 16:59:07 -04:00
Carlos Antonio da Silva
a4dd8719e5 Remove another missing test related to draw external routes
Related with 5e7d6bb
2012-06-29 14:55:09 -03:00
José Valim
5e7d6bba79 Revert "Allow loading external route files from the router"
This reverts commit 6acebb38bc0637bc05c19d87f8767f16ce79189b.

Usage of this feature did not reveal any improvement in existing apps.

Conflicts:

	actionpack/lib/action_dispatch/routing/mapper.rb
	guides/source/routing.textile
	railties/lib/rails/engine.rb
	railties/lib/rails/paths.rb
	railties/test/paths_test.rb
2012-06-29 17:44:10 +02:00
José Valim
50b6110106 Remove unused responsibilities and add a few load definitions to engines
Since plugins were removed, we can clean up a few methods in engines.
We also use this opportunity to move `load_console`, `load_tasks` and
`load_runner` to Rails::Engine. This means that, if someone wants to
improve script/rails for engines to support console or runner commands,
part of the work is already done.
2012-06-29 17:04:47 +02:00
José Valim
0470ddcf03 Remove unnecessary Railties structure now that plugins are gone 2012-06-29 15:43:16 +02:00
José Valim
dbc43bcce6 Rename RouteInspect to RoutesInspector for consistency 2012-06-29 14:04:24 +02:00
Carlos Antonio da Silva
565d54d9ec Merge pull request #6880 from kennyj/fix_20120628
Fix wrong testcase for db:test:prepare, and wrong environment in AR rake task.
2012-06-27 09:03:34 -07:00
Carlos Antonio da Silva
52f6e47682 Merge pull request #6856 from lexmag/polymorphic_generators
Add polymorphic option to model generator

For instance,

    $ rails g model Product supplier:references{polymorphic}

generate model with `belongs_to :supplier, polymorphic: true` association and appropriate migration.
2012-06-27 08:46:00 -07:00
kennyj
066e839467 Fix wrong testcase. This is a testcase for db:test:prepare. 2012-06-28 00:33:08 +09:00
Aleksey Magusev
94b230e189 Add polymorphic option to model generator
For instance,

    $ rails g model Product supplier:references{polymorphic}

generate model with `belongs_to :supplier, polymorphic: true` association and appropriate migration.

Also fix model_generator_test.rb#L196 and #L201
2012-06-27 18:12:28 +04:00
kennyj
0ebd4f22c5 Change the behavior of db:test:prepare task when schema_format is sql for consistency. 2012-06-26 04:06:45 +09:00
kennyj
9ab805d880 Change the behavior of db:test:clone task when schema_format is sql for consistency. 2012-06-26 04:06:45 +09:00
Richard Huang
a6a4813083 ruby 1.9 hash syntax for generated code
app/controllers/application_controller.rb
app/views/layouts/application.html.erb
config/application.rb
config/routes.rb
test/performance/browsing_test.rb
2012-06-23 20:19:21 +08:00
Rafael Mendonça França
39dec69712 Run the logger tests in isolation 2012-06-19 23:21:00 -03:00
Aaron Patterson
f945d157f7 run the notes tests in isolation 2012-06-19 19:08:13 -07:00
Aaron Patterson
265f13495f run railties tests in parallel, default to 2 cores 2012-06-19 17:08:23 -07:00
Aaron Patterson
7b6efb9cda join any extra args to the tmp path 2012-06-19 16:27:54 -07:00
Aaron Patterson
c445f0d61f expand the tmpdir to the realpath so tests on OS X pass 2012-06-19 15:41:52 -07:00