Taking project from deveopment through test to production (worflow)

've been googling for this for a while wit little joy. Maybe I’m using the wrong search terms but I’m very surprised there is not a howto guide;(,
What I am trying to work out it how to take a project from development to test (and test) and then to production. I will make
the environments the same so I don’t need a staging environment. I am using git(bitbucket) unicorn, Nginx and rbevn. Currently I am actually using vanilla ‘rails server’ in development and realise I need to setup unicorn/Ngnix on my development box (but am not asking about this here as there seems to be good guides for this.
Test
I’ve seen in a few places that I can basically clone by rails development environment to test (including database). I gather this means going to git test branch and running some type of rails command to do this (not sure what or what I need to setup). All I can work out is I need to setup config/environments/test.rb/ & config/database.yml. Then run the tests (I’m looking at http://guides.rubyonrails.org/testing.html so again am not asking for help with testing).
ProductionIn production I have the following setup on the server (in .bashrc)
export RAILS_ENV=production
export APP_PATH=/home/users/funkytwig/user/rails/railsappI only have the master git branch on the production server (so I just need to ‘git pull’). The
first time I move app to production I will have to create the database (rails db:migrate? ro do I need to do something else to create from scratch). Then I need to load some app configuration data, think I know
how to do this, see below.
Then when take a new version of the app I also do git pull, ‘rails db:migrate’ and reload the configuration data.
Exporting config Data
Bit more googling and I found out about ‘rails db:seed:dump’ (http://www.rubydoc.info/gems/seed_dump/0.5.3). So I guess I use something like

rake db:seed:dump MODELS=User, RefValue

Seem to make seance to create a bump_db_app_config.bash to create this file, although not sure exactly where to put
it in the file-system (should put the script and created file in rails app structure some-ware or outside it)

Lastly alter I have migrated the db I just run the script.

've been googling for this for a while wit little joy. Maybe I’m using the
wrong search terms but I’m very surprised there is not a howto guide;(,

What I am trying to work out it how to take a project from development to
test (and test) and then to production.

Putting your app into production is usually called "deployment"; you
should be able to find lots of references to that, but most Rails apps
use Capistrano (highly recommended).

Test
I've seen in a few places that I can basically clone by rails development
environment to test (including database). I gather this means going to git
test branch and running some type of rails command to do this (not sure what
or what I need to setup). All I can work out is I need to setup
config/environments/test.rb/ & config/database.yml.

"git test branch"? What? Running tests has nothing to do with any
particular git branch. And ideally you'd be writing and running tests
continually throughout development.

Exporting config Data
Bit more googling and I found out about 'rails db:seed:dump'
(http://www.rubydoc.info/gems/seed_dump/0.5.3). So I guess I use something
like

rake db:seed:dump MODELS=User, RefValue

What are you calling "config data"? It's not usually something that's
associated with the DB.

Thanks for your reply,

I think I can work out most of the stuff but its the
cloning the dev (db) into test that I cant work out. Seem to remember it saying something in the ruby config about the test database being re-writern from development (not sure how/when)

More comments in-line below.

've been googling for this for a while wit little joy. Maybe I’m using the

wrong search terms but I’m very surprised there is not a howto guide;(,

What I am trying to work out it how to take a project from development to

test (and test) and then to production.

Putting your app into production is usually called “deployment”; you

should be able to find lots of references to that, but most Rails apps

use Capistrano (highly recommended).

Thanks, deployment yes, in terms of Capistrano will look into it but currently only have 5 pages and a lot of the data is loaded from outside rails (the load scripts already existed). In time will look into it. I feel better knowing how things work manually before going the automated route.

Test

I’ve seen in a few places that I can basically clone by rails development

environment to test (including database). I gather this means going to git

test branch and running some type of rails command to do this (not sure what

or what I need to setup). All I can work out is I need to setup

config/environments/test.rb/ & config/database.yml.

“git test branch”? What? Running tests has nothing to do with any

particular git branch. And ideally you’d be writing and running tests

continually throughout development.

Sorry ‘git checkout test’. I have develop, test and master branches. When I am ready to test for a release I merge develop into test. Cant see how I don’t want to be in test branch for testing or am I doing this all wrong.

Exporting config Data

Bit more googling and I found out about ‘rails db:seed:dump’

(http://www.rubydoc.info/gems/seed_dump/0.5.3). So I guess I use something

like

rake db:seed:dump MODELS=User, RefValue

What are you calling “config data”? It’s not usually something that’s

associated with the DB.

There are a few tables, i.e. one tells the data load scripts which XML feeds to use to load data and other data to do with music venues. I prefer doing this as data input forms as it means I can access the data easily from rails (venue name, address, phone number) and validate data. Its data feed configuration which is setup by admins. Think seeds.rb is the answer here.

Ben

Thanks for your reply,

I think I can work out most of the stuff but its the cloning the dev (db) into test that I cant work out. Seem to remember it saying something in the ruby config about the test database being re-writern from development (not sure how/when)

If you have written migrations as you go, then the test database can be created and structured by calling the following two rake commands:

rake db:create RAILS_ENV=test
rake db:migrate RAILS_ENV=test

If you have any seeds, then follow those with:

rake db:seed RAILS_ENV=test

I believe there are additional rake tasks specific to test setup that may condense all of the above into a one-liner, you can see the entire list of rake tasks by issuing this command (from within your rails project directory:

rake -T

Your tests should not rely on any data besides what you add using seeds or fixtures, as the test database may (should) be emptied and re-initialized multiple times during a single testing run. So your comment about "cloning" the dev DB into test may indicate that you need some more information about how Rails tests run in general than you have at present.

A good first stop is here: http://guides.rubyonrails.org/testing.html and if you haven't done so already, you should definitely take a couple of days to work all the way through https://railstutorial.org which is free to use online. If you haven't gone through this tutorial in the last two years, you should probably do it again, too. I've been using Rails since version 1, and I learned a few things the last time I went through it. Hands-down, it is probably the best-written technical training material I have ever used.

Walter

You want to test the code you're writing, whatever you call the branch
it's in. I've personally never seen or heard of anyone using a separate
"test" branch and can't imagine a reason for it.

This sounds like a concept known as “staging”.

Testing usually means having small pieces of code called unit-tests or
specs, which do test your code automatically.

Those tests are written iteratively and close in time to the code they
are testing and usually run in an environment similar to the
dev-environment.

The “staging” concept though, does run the same tests and optionally
additional manual tests, scripted or not, in an environment that is as
close as possible to the actual production environment. Hardware,
operating system, even the smallest system library version should be
identical to the prod environment.

Usually also some stresstrests are made in this environment to ensure
the application is capable to manage the expected load (or even more).

Thanks, so the testing database is used for unit testing (and I don’t have to worry about creating it/emptying as rails does this for me?). I guess I was talking about integration testing, witch sounds like what people mean when they talk about staging. Ive previously worked in telecoms doing Oracle DB development. There they talked about integration testing, performance testing and unit testing.

This is the first time ive taken something from development to production myself. What I have currently is a single public page (based on a view) and some almost vanilla scaffold created screens. They set up configuration (XML feeds etc.) for a bunch of load scripts, that were writern previously in ruby (before I started looking at rails). Also devise to protest them.

The plan is to get it up as a proof of concept so people can look at it then start looking at testing in detail.

Thanks everyone for taking the time to reply, it is really appreciated.

Thanks for that, stated looking at the testing guide but was confused as to how to setup the test database. It seems it is talking about unit testing and does all the setup/pull down in the background.

https://www.google.com/url?q=https%3A%2F%2Frailstutorial.org&sa=D&sntz=1&usg=AFQjCNHycyJCw8I6pyES5ucJMACNfAHfrgHad a glance through the rails guide and it looks great. Shame I can just buy it, ime not a big fan of the subscription model.

Thansks,
Ben

Thanks for that, stated looking at the testing guide but was confused as to
how to setup the test database. It seems it is talking about unit testing
and does all the setup/pull down in the background.

As has already been suggested, work right through the
railstutorial.org tutorial, it covers unit and integration tests
(unless it has changed since I last looked). Staging is something
different.

Colin