repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/sensors_helper_spec.rb
spec/helpers/sensors_helper_spec.rb
require "spec_helper" describe SensorsHelper do end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/pages_helper_spec.rb
spec/helpers/pages_helper_spec.rb
require "spec_helper" describe PagesHelper do end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/users_helper_spec.rb
spec/helpers/users_helper_spec.rb
require "spec_helper" describe UsersHelper do end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
require 'spec_helper' describe ApplicationHelper do describe "#navigation" do it "puts the block inside a <ul> within <nav>" do html = helper.navigation { "Home" } html.should == "<nav><ul>Home</ul></nav>" end end describe "#navigate_to" do it "generates a link inside an <li> tag" do html = helper.navigate_to(:home, "Home", "/") html.should == "<li>" + link_to("Home", "/") + "</li>" end it "it adds the class 'active' when the page is active " do @navigation_id = :home html = helper.navigate_to(:home, "Home", "/") html.should == "<li>" + link_to("Home", "/", :class => "active") + "</li>" end it "respects existing classes" do html = helper.navigate_to(:home, "Home", "/", :class => "large") html.should == "<li>" + link_to("Home", "/", :class => "large") + "</li>" html = helper.navigate_to(:home, "Home", "/", :class => ["large"]) html.should == "<li>" + link_to("Home", "/", :class => "large") + "</li>" @navigation_id = :home expected_link = link_to("Home", "/", :class => "large active") html = helper.navigate_to(:home, "Home", "/", :class => "large") html.should == "<li>#{expected_link}</li>" end end describe "#body_id" do it "identifies the page from its controller and actions names" do helper.stub :controller_name => "posts" helper.stub :action_name => "show" helper.body_id.should == "posts_show" end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/sites_helper_spec.rb
spec/helpers/sites_helper_spec.rb
require "spec_helper" describe SitesHelper do end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/models/page_spec.rb
spec/models/page_spec.rb
require "spec_helper" describe Page do let :site do Factory :site, :time_zone => "Helsinki" end let :page_counts do Mongo.db["page_counts"] end describe "#site" do it "is the site of the page" do page = Page.new("s" => site.bson_id) page.site.should == site end end describe "#time_zone" do it "is the time zone of the associated site" do page = Page.new("s" => site.bson_id) page.time_zone.should == "Helsinki" end end describe "#[]" do it "delegates to the document" do page = Page.new("a" => "A", "b" => "B") page["a"].should == "A" page["b"].should == "B" end end describe "#uri" do it "returns the value for the 'u' key" do page = Page.new("u" => "URI") page.uri.should == "URI" end end describe "#hash" do let(:page) { Page.new("h" => "HASH") } it "returns the value for the 'h' key" do page.hash.should == "HASH" end it "is aliased as #to_param" do page.to_param.should == "HASH" end end describe ".find" do before do page_counts.insert( :h => "HASH", :s => site.bson_id, :y => 2011 ) end it "returns a Page object for a given site, hash and year" do page = Page.find(site, "HASH", 2011) page["s"].should == site.bson_id page["h"].should == "HASH" page["y"].should == 2011 end it "raises an ActiveRecord::RecordNotFound when no document is found" do lambda { Page.find(site, "FOOBAR") }.should raise_error(ActiveRecord::RecordNotFound) end end describe "#counter_data" do before do page_counts.insert({ "s" => site.bson_id, "h" => "HASH", "y" => 2011, "3" => { "4" => { "c" => 50 } } }) page_counts.insert({ "s" => site.bson_id, "h" => "FOO", "y" => 2011, "3" => { "4" => { "c" => 25 } } }) end it "contains the total pageviews for the current day" do page_counts.insert({ "s" => site.bson_id, "h" => "HASH", "y" => 2011, "3" => { "4" => { "c" => 50 } } }) page = Page.find(site, "HASH", 2011) Timecop.freeze(Time.utc(2011, 3, 4, 12)) page.counter_data[:pageviews_today].should == 50 Timecop.freeze(Time.utc(2011, 1, 1)) page.counter_data[:pageviews_today].should == 0 end it "contains the number of active visitors" do visits = Mongo.db["visits"] visits.insert({ "s" => site.bson_id, "p" => ["HASH"], "h" => Time.new(2011, 11, 11, 11, 45).to_i }) visits.insert({ "s" => site.bson_id, "p" => ["FOO"], "h" => Time.new(2011, 11, 11, 11, 50).to_i }) visits.insert({ "s" => site.bson_id, "p" => ["HASH", "FOO"], "h" => Time.new(2011, 11, 11, 11, 55).to_i }) page_hash = Page.find(site, "HASH", 2011) page_foo = Page.find(site, "FOO", 2011) Timecop.freeze(Time.new(2011, 11, 11, 12)) page_hash.counter_data[:active_visitors].should == 1 page_foo.counter_data[:active_visitors].should == 2 end end describe "#chart_data" do it "contains today's pageviews" do Timecop.freeze(Time.utc(2011, 6, 8, 12)) page_counts.insert({ "s" => site.bson_id, "y" => 2011, "h" => "CDT", "6" => { "8" => { "7" => { "c" => 100 }, "10" => { "c" => 300 } } } }) expected = 16.times.map { |i| [i, 0] } expected[7][1] = 100 expected[10][1] = 300 page = Page.find(site, "CDT", 2011) page.chart_data[:today].should == expected end it "contains yesterday's pageviews" do Timecop.freeze(Time.utc(2011, 12, 7, 14)) page_counts.insert({ "s" => site.bson_id, "y" => 2011, "h" => "CDY", "12" => { "6" => { "3" => { "c" => 20 }, "6" => { "c" => 10 } } } }) expected = 24.times.map { |i| [i, 0] } expected[3][1] = 20 expected[6][1] = 10 page = Page.find(site, "CDY", 2011) page.chart_data[:yesterday].should == expected end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/models/site_spec.rb
spec/models/site_spec.rb
require "spec_helper" describe Site do let(:site) { Factory :site, :time_zone => "Helsinki" } let(:site_counts_collection) { Mongo.db["site_counts"] } let(:sites_collection) { Mongo.db["sites"] } it { should validate_presence_of(:name) } it { should have_many(:sensors).dependent(:destroy) } describe "#save" do context "successful" do it "creates a MongoDB document with site information" do document = sites_collection.find_one(site.bson_id) document["tz"].should == "Europe/Helsinki" end end context "rollback" do it "removes the MongoDB document" do Site.transaction do sites_collection.find_one(site.bson_id).should_not be_nil raise ActiveRecord::Rollback end sites_collection.find_one(site.bson_id).should be_nil end end end describe "#destroy" do it "removes the MongoDB document" do site.destroy sites_collection.find_one(site.bson_id).should be_nil end end describe "#time_zone_id" do it "returns the TZInfo indentifier" do site = Site.new(:time_zone => "Helsinki") site.time_zone_id.should == "Europe/Helsinki" end end describe "#bson_id" do it "returns a BSON::ObjectId from the token" do token = "4d73838feca02647cd000001" site = Site.new(:token => token) site.bson_id.should == BSON::ObjectId(token) end end describe "#counter_data" do it "contains the total pageviews for the current day" do site_counts_collection.insert({ "s" => site.bson_id, "y" => 2011, "1" => { "6" => { "c" => 200 } } }) Timecop.freeze(Time.utc(2011, 1, 6, 12)) site.counter_data[:pageviews_today].should == 200 Timecop.freeze(Time.utc(2011, 1, 1)) site.counter_data[:pageviews_today].should == 0 end it "contains the number of active visitors" do visits = Mongo.db["visits"] visits.insert({ "s" => site.bson_id, "h" => Time.new(2011, 11, 11, 11, 45).to_i }) visits.insert({ "s" => site.bson_id, "h" => Time.new(2011, 11, 11, 11, 50).to_i }) visits.insert({ "s" => site.bson_id, "h" => Time.new(2011, 11, 11, 11, 55).to_i }) Timecop.freeze(Time.new(2011, 11, 11, 12)) site.counter_data[:active_visitors].should == 2 end it "contains the number of unique visitors for the current day" do visitors = Mongo.db["visitors"] visitors.insert({ "s" => site.bson_id, "u" => "A", "d" => "2011-01-01" }) visitors.insert({ "s" => site.bson_id, "u" => "B", "d" => "2011-01-01" }) visitors.insert({ "s" => site.bson_id, "u" => "C", "d" => "2011-01-02" }) Timecop.freeze(Time.utc(2011, 1, 1, 12)) site.counter_data[:visitors_today].should == 2 Timecop.freeze(Time.utc(2010, 12, 31, 23)) site.counter_data[:visitors_today].should == 2 Timecop.freeze(Time.utc(2011, 1, 2)) site.counter_data[:visitors_today].should == 1 end end describe "#chart_data" do it "contains today's pageviews" do Timecop.freeze(Time.utc(2011, 6, 8, 12)) site_counts_collection.insert({ "s" => site.bson_id, "y" => 2011, "6" => { "8" => { "7" => { "c" => 100 }, "10" => { "c" => 300 } } } }) expected = 16.times.map { |i| [i, 0] } expected[7][1] = 100 expected[10][1] = 300 site.chart_data[:today].should == expected end it "contains yesterday's pageviews" do Timecop.freeze(Time.utc(2011, 12, 7, 14)) site_counts_collection.insert({ "s" => site.bson_id, "y" => 2011, "12" => { "6" => { "3" => { "c" => 20 }, "6" => { "c" => 10 } } } }) expected = 24.times.map { |i| [i, 0] } expected[3][1] = 20 expected[6][1] = 10 site.chart_data[:yesterday].should == expected end end describe "#tracked?" do it "is true when there are no registered clicks" do site_counts_collection.find("s" => site.bson_id).count.should == 0 site.should_not be_tracked end it "is false when there are registered clicks" do site_counts_collection.insert("s" => site.bson_id, "y" => 2011, "c" => 1) site.should be_tracked end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/models/sensor_spec.rb
spec/models/sensor_spec.rb
require "spec_helper" describe Sensor do it { should have_many(:hosts) } it { should belong_to(:site) } it { should validate_presence_of(:name) } it { should validate_presence_of(:type) } let(:site) { Factory :site } let(:sensor_counts_collection) { Mongo.db["sensor_counts"] } let :campaign do Factory :sensor, :site => site, :type => "query", :uri_query_key => "campaign", :uri_query_value => "fr11" end let :newsletter do Factory :sensor, :site => site, :type => "query", :uri_query_key => "from", :uri_query_value => "newsletter" end let :social_media do sensor = Factory :sensor, :site => site, :type => "referrer" Factory(:sensor_host, :host => "facebook.com", :sensor => sensor) Factory(:sensor_host, :host => "twitter.com", :sensor => sensor) sensor end describe "#save" do it "syncs the sensor data with MongoDB" do campaign sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 1 sensors.should include({ "id" => campaign.id, "type" => "query", "key" => "campaign", "value" => "fr11" }) newsletter sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 2 sensors.should include({ "id" => newsletter.id, "type" => "query", "key" => "from", "value" => "newsletter" }) social_media sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 3 sensors.should include({ "id" => social_media.id, "type" => "referrer", "hosts" => ["facebook.com", "twitter.com"] }) campaign.uri_query_value = "fr12" campaign.save! sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 3 sensors.should include({ "id" => campaign.id, "type" => "query", "key" => "campaign", "value" => "fr12" }) end end describe "#destroy" do it "syncs the sensor data with MongoDB" do campaign newsletter sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 2 newsletter.destroy sensors = Mongo.db["sites"].find_one(site.bson_id)["sensors"] sensors.count.should == 1 sensors.should include({ "id" => campaign.id, "type" => "query", "key" => "campaign", "value" => "fr11" }) end end describe "#uri_query_key" do context "query based sensor" do it "is required" do sensor = Factory.build :sensor, :type => "query" sensor.should validate_presence_of(:uri_query_key) end end context "host based sensor" do it "is not required" do sensor = Factory.build :sensor, :type => "host" sensor.should_not validate_presence_of(:uri_query_key) end end end describe "#uri_query_value" do context "query based sensor" do it "is required" do sensor = Factory.build :sensor, :type => "query" sensor.should validate_presence_of(:uri_query_value) end end context "host based sensor" do it "is not required" do sensor = Factory.build :sensor, :type => "host" sensor.should_not validate_presence_of(:uri_query_value) end end end describe "nested attributes for hosts" do it "rejects empty hosts" do sensor = Sensor.new sensor.hosts_attributes = { "1" => { "host" => "google.com" }, "2" => { "host" => " " } } sensor.hosts.length.should == 1 end it "rejects duplicates" do sensor = Sensor.new sensor.hosts_attributes = { "1" => { "host" => "google.com" }, "2" => { "host" => "google.com" } } sensor.hosts.length.should == 1 end end describe "#chart_data" do let(:sensor) { Factory :sensor, :site => site } it "contains today's entries" do Timecop.freeze(Time.utc(2011, 7, 2, 12)) sensor_counts_collection.insert({ "s" => site.bson_id, "y" => 2011, "id" => sensor.id, "7" => { "2" => { "10" => { "c" => 20 }, "12" => { "c" => 60 } } } }) expected = 16.times.map { |i| [i, 0] } expected[10][1] = 20 expected[12][1] = 60 sensor.chart_data[:today].should == expected end it "contains yesterday's entries" do Timecop.freeze(Time.utc(2011, 7, 2, 12)) sensor_counts_collection.insert({ "s" => site.bson_id, "y" => 2011, "id" => sensor.id, "7" => { "1" => { "14" => { "c" => 15 }, "19" => { "c" => 30 } } } }) expected = 24.times.map { |i| [i, 0] } expected[14][1] = 15 expected[19][1] = 30 sensor.chart_data[:yesterday].should == expected end end describe "#time_zone" do it "returns the time zone of the site" do sensor = Factory :sensor, :site => site sensor.time_zone.should == sensor.site.time_zone end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/models/sensor_host_spec.rb
spec/models/sensor_host_spec.rb
require "spec_helper" describe SensorHost do before do Factory :sensor_host end it { should belong_to(:sensor) } it { should validate_presence_of(:host) } it { should validate_uniqueness_of(:host).scoped_to(:sensor_id) } end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/models/user_spec.rb
spec/models/user_spec.rb
require 'spec_helper' describe User do describe "on create" do context "no password specified" do it "generates a random password" do user = Factory :user, :password => nil user.password.should_not be_nil user.password.should_not be_empty end end context "password specified" do it "uses the specified password" do user = Factory :user, :password => "monkey" user.password.should == "monkey" end end it "sends an email with the password to the user" do Factory :user, :email => "lucy@snowfinch.net", :password => "passw0rd" email = last_email_sent email.should deliver_to("lucy@snowfinch.net") email.should have_subject("Account for snowfinch.rails.fi:3000") email.should have_body_text(/lucy@snowfinch.net/) email.should have_body_text(/passw0rd/) end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/pages_spec.rb
spec/acceptance/pages_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Pages" do let :site do site = Factory :site end background do sign_in :user Mongo.db["site_counts"].insert("s" => site.bson_id) end scenario "Viewing a page" do Mongo.db["page_counts"].insert( "s" => site.bson_id, "h" => "ddh1rWSO1CR8Bt2J6AitMv733fp", "u" => "http://rails.fi/" ) visit site_page(site) fill_in "page_uri", :with => "http://rails.fi/" click_button "View stats" page.should have_title("http://rails.fi/") current_path.should == "/sites/#{site.id}/pages/ddh1rWSO1CR8Bt2J6AitMv733fp" end scenario "Viewing a page with no data" do visit site_page(site) fill_in "page_uri", :with => "http://rails.fi/" click_button "View stats" page.should have_title("Not found") page.should have_content("Sorry, there is no data for the requested page.") end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/navigation_spec.rb
spec/acceptance/navigation_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Navigation" do scenario "Signed out" do visit sign_in_page page.all("body > header nav ul li").should be_empty end scenario "Signed in" do sign_in :user within "body > header nav" do page.should have_link("Sites", :href => sites_page) page.should have_link("Users", :href => users_page) page.should have_link("Sign out") end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/users_spec.rb
spec/acceptance/users_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Users" do background do @joe = sign_in :user, :email => "joe@snowfinch.net" end scenario "Browsing users" do aaron = Factory :user, :email => "aaron@snowfinch.net" ted = Factory :user, :email => "ted@snowfinch.net" visit users_page page.should have_title("Users") page.should have_active_navigation("Users") page.should have_link("joe@snowfinch.net", :href => user_page(@joe)) page.should have_link("aaron@snowfinch.net", :href => user_page(aaron)) page.should have_link("ted@snowfinch.net", :href => user_page(ted)) page.all("ul.list a").map(&:text).should == ["aaron@snowfinch.net", "joe@snowfinch.net", "ted@snowfinch.net"] end scenario "Viewing a user" do visit user_page(@joe) page.should have_title("joe@snowfinch.net") page.should have_active_navigation("Users") end scenario "Adding a user" do visit users_page click_link "Add a user" current_path.should == new_user_page page.should have_title("Add a user") page.should have_active_navigation("Users") page.should have_content("The user will receive an email with a password.") fill_in "Email", :with => "jack@snowfinch.net" click_button "Add" page.should have_notice('"jack@snowfinch.net" has been added.') current_path.should == users_page end scenario "Removing a user" do luke = Factory :user, :email => "luke@snowfinch.net" visit user_page(luke) click_button "Remove this user" page.should have_notice('"luke@snowfinch.net" has been removed.') current_path.should == users_page end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/sites_spec.rb
spec/acceptance/sites_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Sites" do background do sign_in :user end scenario "Browsing sites" do blog = Factory :site, :name => "Blog" api = Factory :site, :name => "API docs" info = Factory :site, :name => "Info" visit sites_page page.should have_title("Sites") page.should have_active_navigation("Sites") page.should have_link("API docs", :href => site_page(api)) page.should have_link("Blog", :href => site_page(blog)) page.should have_link("Info", :href => site_page(info)) page.all("ul.list a").map(&:text).should == ["API docs", "Blog", "Info"] end scenario "Adding a site" do visit sites_page click_link "Add a site" current_path.should == new_site_page page.should have_title("Add a site") page.should have_active_navigation("Sites") fill_in "Site name", :with => "Snowfinch info" select "Helsinki", :from => "Time zone" click_button "Save" page.should have_notice('"Snowfinch info" has been created.') current_path.should == site_page(Site.last) end scenario "Viewing a site" do site = Factory :site, :name => "Snowfinch blog" visit site_page(site) page.should have_title("Snowfinch blog") page.should have_active_navigation("Sites") end scenario "Editing a site" do site = Factory :site, :name => "Snowfinch blog" visit site_page(site) click_link "Edit" page.should have_title('Edit "Snowfinch blog"') page.should have_active_navigation("Sites") current_path.should == edit_site_page(site) fill_in "Site name", :with => "Snowfinch development blog" click_button "Save" page.should have_notice('"Snowfinch development blog" has been updated.') current_path.should == site_page(site) end scenario "Failed editing" do site = Factory :site, :name => "Snowfinch info" visit edit_site_page(site) fill_in "Site name", :with => "" click_button "Save" page.should have_title('Edit "Snowfinch info"') end scenario "Removing a site" do site = Factory :site, :name => "Old Snowfinch blog" visit edit_site_page(site) click_button "Remove this site" page.should have_notice('"Old Snowfinch blog" has been removed.') current_path.should == sites_page end scenario "No sites exist" do visit sites_page message = %{You don't have any sites. Click "Add a site" to create one.} page.should have_content(message) end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/acceptance_helper.rb
spec/acceptance/acceptance_helper.rb
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") require "steak" # Put your acceptance spec helpers inside /spec/acceptance/support Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/account_spec.rb
spec/acceptance/account_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Account" do background do sign_in :user, :email => "user@snowfinch.net", :password => "snowfinch" end scenario "Edit own account" do visit homepage click_link "Account" page.should have_active_navigation("Account") page.should have_title("Account") fill_in "Email", :with => "joao@snowfinch.net" fill_in "Password", :with => "joaojoao" fill_in "Password confirmation", :with => "joaojoao" fill_in "Current password", :with => "snowfinch" click_button "Save" page.should have_notice("Your account has been updated.") current_path.should == homepage click_link "Sign out" fill_in "Email", :with => "joao@snowfinch.net" fill_in "Password", :with => "joaojoao" click_button "Sign in" page.should have_notice("Welcome, you are now signed in.") end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/authentication_spec.rb
spec/acceptance/authentication_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Authentication" do background do Factory :user, :email => "jason@snowfinch.net", :password => "123456" end scenario "Signing in" do visit sign_in_page fill_in "Email", :with => "jason@snowfinch.net" fill_in "Password", :with => "123456" click_button "Sign in" page.should have_notice("Welcome, you are now signed in.") current_path.should == sites_page end scenario "Accessing a restricted page while signed out" do visit sites_page current_path.should == sign_in_page page.should have_notice("You must sign in to access the requested page.") end scenario "Failed sign in" do visit sign_in_page click_button "Sign in" page.should have_notice("Invalid email and/or password. Please try again.") end scenario "Logging out" do sign_in :user click_link "Sign out" current_path.should == sign_in_page end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/monitoring_spec.rb
spec/acceptance/monitoring_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature "Monitoring" do let(:site) { Factory :site } background do sign_in :user end scenario "No sensors exist" do visit sensors_page(site) message = %{You don't have any sensors. Click "Add a sensor" to create one.} page.should have_content(message) end scenario "Browsing sensors" do some = Factory :sensor, :name => "Social Media", :site => site bacon = Factory :sensor, :name => "Bacon Campaign", :site => site visit site_page(site) click_link "Monitoring" page.should have_title("Monitoring") page.should have_active_navigation("Sites") current_path.should == sensors_page(site) page.should have_link("Social Media", :href => sensor_page(some)) page.should have_link("Bacon Campaign", :href => sensor_page(bacon)) end scenario "Creating a query based sensor" do visit sensors_page(site) click_link "Add a sensor" page.should have_title("Add a sensor") page.should have_active_navigation("Sites") current_path.should == new_sensor_page(site) within "#query_sensor_form" do fill_in "Sensor name", :with => "Summer Discount" fill_in "URI query key", :with => "campaign" fill_in "URI query value", :with => "summer_discount" click_button "Save" end page.should have_notice('"Summer Discount" has been created.') current_path.should == sensor_page(Sensor.last) end scenario "Creating a referrer based sensor", :js => true do visit new_sensor_page(site) click_link "Referrer based" within "#referrer_sensor_form" do fill_in "Sensor name", :with => "Social Media" click_link "Add a referrer" fill_in "Referrer host", :with => "facebook.com" click_link "Add a referrer" within(".referrer:last") do fill_in "Referrer host", :with => "twitter.com" end click_link "Add a referrer" within(".referrer:last") do fill_in "Referrer host", :with => "snowfinch.net" click_link "remove" end click_button "Save" end page.should have_notice('"Social Media" has been created.') current_path.should == sensor_page(Sensor.last) # It's a complex form with JavaScript manipulating nested attributes. This # is the easiest way to make sure the hosts get created. Sensor.last.hosts.count.should == 2 Sensor.last.hosts.where(:host => "facebook.com").count.should == 1 Sensor.last.hosts.where(:host => "twitter.com").count.should == 1 end scenario "Toggling between query and referrer creation forms", :js => true do visit new_sensor_page(site) page.should have_title("Add a sensor") find("#query_sensor_form").should be_visible find("#referrer_sensor_form").should_not be_visible page.should have_css("#query_based_toggle.active") page.should_not have_css("#referrer_based_toggle.active") click_link "Referrer based" find("#query_sensor_form").should_not be_visible find("#referrer_sensor_form").should be_visible page.should_not have_css("#query_based_toggle.active") page.should have_css("#referrer_based_toggle.active") click_link "Query based" find("#query_sensor_form").should be_visible find("#referrer_sensor_form").should_not be_visible page.should have_css("#query_based_toggle.active") page.should_not have_css("#referrer_based_toggle.active") end scenario "Viewing a sensor" do sensor = Factory :sensor, :name => "SoMe", :site => site visit sensor_page(sensor) page.should have_title("SoMe") page.should have_active_navigation("Sites") end scenario "Editing a query based sensor" do sensor = Factory :sensor, :name => "FR10", :type => "query", :uri_query_key => "campaign", :uri_query_value => "fr10", :site => site visit sensor_page(sensor) click_link "Edit" fill_in "Sensor name", :with => "FR11" fill_in "URI query value", :with => "fr11" click_button "Save" page.should have_notice(%{"FR11" has been updated.}) current_path.should == sensor_page(sensor) page.should have_title("FR11") end scenario "Editing a referrer based sensor", :js => true do sensor = Factory :sensor, :name => "SoMe", :type => "referrer", :site => site host_1 = Factory :sensor_host, :host => "facebook.co", :sensor => sensor host_2 = Factory :sensor_host, :host => "twitter.com", :sensor => sensor host_3 = Factory :sensor_host, :host => "myspace.com", :sensor => sensor visit sensor_page(sensor) click_link "Edit" fill_in "Sensor name", :with => "Social Media" within :xpath, "//div[@class='referrer'][1]" do fill_in "Referrer host", :with => "facebook.com" end within :xpath, "//div[@class='referrer'][3]" do check "remove" end click_link "Add a referrer" within :xpath, "//div[contains(@class,'referrer')][4]" do fill_in "Referrer host", :with => "jaiku.com" end click_button "Save" page.should have_title("Social Media") page.should have_notice('"Social Media" has been updated.') sensor.hosts.count.should == 3 sensor.hosts.where(:host => "facebook.com").count.should == 1 sensor.hosts.where(:host => "twitter.com").count.should == 1 sensor.hosts.where(:host => "jaiku.com").count.should == 1 end scenario "Removing a sensor" do sensor = Factory :sensor, :name => "Google", :site => site visit edit_sensor_page(sensor) click_button "Remove this sensor" page.should have_notice('"Google" has been removed.') current_path.should == sensors_page(site) end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/support/matchers.rb
spec/acceptance/support/matchers.rb
module AcceptanceMatchers def has_title?(title) has_css?("h1", :text => title) end def has_active_navigation?(link_text) has_css?("body > header nav a.active", :text => link_text) end def has_notice?(text) has_css?("#flash", :text => text) end end Capybara::Node::Base.send :include, AcceptanceMatchers
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/support/helpers.rb
spec/acceptance/support/helpers.rb
module HelperMethods def sign_in(resource_name, factory_opts={}) resource = Factory(resource_name, factory_opts) visit sign_in_page fill_in "Email", :with => resource.email fill_in "Password", :with => resource.password click_button "Sign in" resource end end RSpec.configuration.include HelperMethods, :type => :acceptance
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/acceptance/support/paths.rb
spec/acceptance/support/paths.rb
module NavigationHelpers def homepage "/" end def sign_in_page "/users/sign_in" end def sites_page "/sites" end def site_page(site) "/sites/#{site.id}" end def new_site_page "/sites/new" end def edit_site_page(site) "/sites/#{site.id}/edit" end def users_page "/users" end def user_page(user) "/users/#{user.id}" end def new_user_page "/users/new" end def sensors_page(site) "/sites/#{site.id}/sensors" end def sensor_page(sensor) "/sites/#{sensor.site_id}/sensors/#{sensor.id}" end def new_sensor_page(site) "/sites/#{site.id}/sensors/new" end def edit_sensor_page(sensor) "/sites/#{sensor.site_id}/sensors/#{sensor.id}/edit" end end RSpec.configuration.include NavigationHelpers, :type => :acceptance
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/lib/mongo_ext.rb
lib/mongo_ext.rb
require "mongo" require "configuration" module Mongo def self.db @db ||= Mongo::Connection.new.db(Snowfinch.configuration["mongo_database"]) end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/lib/configuration.rb
lib/configuration.rb
require "yaml" module Snowfinch def self.configuration @configuration ||= begin yaml = File.read(Rails.root.join("config/snowfinch.yml")) YAML.load(yaml)[Rails.env].with_indifferent_access end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/compass.rb
config/compass.rb
# This configuration file works with both the Compass command line tool and within Rails. # Require any additional compass plugins here. project_type = :rails project_path = Compass::AppIntegration::Rails.root # Set this to the root of your project when deployed: http_path = "/" css_dir = "public/stylesheets" sass_dir = "app/stylesheets" environment = Compass::AppIntegration::Rails.env # To enable relative paths to assets via compass helper functions. Uncomment: # relative_assets = true
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/application.rb
config/application.rb
require File.expand_path("../boot", __FILE__) require "rails/all" require "benchmark" Bundler.require(:default, Rails.env) if defined?(Bundler) module Snowfinch class Application < Rails::Application require Rails.root.join("lib/configuration.rb") # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W(#{config.root}/concerns) # Set Time.zone default to the specified zone and make Active Record # auto-convert to this zone. Run "rake -D time" for a list of tasks for # finding time zone names. Default is UTC. config.time_zone = "Helsinki" # Default JavaScript files. config.action_view.javascript_expansions[:defaults] = %w(jquery jquery.flot rails) # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] # We do acceptance testing. config.app_generators.controller_specs false config.app_generators.request_specs false config.app_generators.routing_specs false config.app_generators.view_specs false # Host to link to in mailers. Look at config/snowfinch.yml for the values. config.action_mailer.default_url_options = { :host => Snowfinch.configuration[:host] } end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/environment.rb
config/environment.rb
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Snowfinch::Application.initialize!
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/routes.rb
config/routes.rb
Snowfinch::Application.routes.draw do devise_for :users unless Snowfinch.configuration[:mount_collector] == false match "/collector" => Snowfinch::Collector end resources :sites do member do get :counters get :chart end resources :sensors do member do get :chart end end resources :pages do collection do post :find end member do get :counters get :chart end end end resources :users resource :account root :to => "sites#index" end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/boot.rb
config/boot.rb
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/snowfinch.rb
config/initializers/snowfinch.rb
require Rails.root.join("lib/configuration.rb") require Rails.root.join("lib/mongo_ext.rb") Snowfinch::Collector.db = Mongo.db if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| if forked Mongo.db.connection.connect end end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Snowfinch::Application.config.session_store :cookie_store, :key => '_snowfinch_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") # Snowfinch::Application.config.session_store :active_record_store
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/devise.rb
config/initializers/devise.rb
require Rails.root.join("lib/configuration.rb") # Use this hook to configure devise mailer, warden hooks and so forth. The first # four configuration values can also be set straight in your models. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in DeviseMailer. config.mailer_sender = Snowfinch.configuration[:mailer_sender] # Configure the class responsible to send e-mails. config.mailer = "Devise::Mailer" # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. require 'devise/orm/active_record' # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating an user. By default is # just :email. You can configure it to use [:username, :subdomain], so for # authenticating an user, both parameters are required. Remember that those # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. # config.authentication_keys = [ :email ] # Tell if authentication through request.params is enabled. True by default. # config.params_authenticatable = true # Tell if authentication through HTTP Basic Auth is enabled. False by default. # config.http_authenticatable = false # Set this to true to use Basic Auth for AJAX requests. True by default. # config.http_authenticatable_on_xhr = true # The realm used in Http Basic Authentication # config.http_authentication_realm = "Application" # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. config.stretches = 10 # Setup a pepper to generate the encrypted password. config.pepper = "c3476f4621d4f052088cc90ffbeecffe51db2e1d38f6c697b152deb6f0b189d434d337befcaa37072605fff8f41f950054ec8bfae847551ce42b82f874d692fd" # ==> Configuration for :confirmable # The time you want to give your user to confirm his account. During this time # he will be able to access your application without confirming. Default is nil. # When confirm_within is zero, the user won't be able to sign in without confirming. # You can use this to let your user access some features of your application # without confirming the account, but blocking it after a certain period # (ie 2 days). # config.confirm_within = 2.days # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks # If true, a valid remember token can be re-used between multiple browsers. # config.remember_across_browsers = true # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false # ==> Configuration for :validatable # Range for password length config.password_length = 6..128 # Regex to use to validate the email address # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. # config.timeout_in = 10.minutes # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. # :none = No lock strategy. You should handle locking by yourself. # config.lock_strategy = :failed_attempts # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email # :time = Re-enables login after a certain amount of time (see :unlock_in below) # :both = Enables both strategies # :none = No unlock strategy. You should handle unlocking by yourself. # config.unlock_strategy = :both # Number of authentication tries before locking an account if lock_strategy # is failed attempts. # config.maximum_attempts = 20 # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour # ==> Configuration for :token_authenticatable # Defines name of the authentication token params key # config.token_authentication_key = :auth_token # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. # config.scoped_views = true # Configure the default scope given to Warden. By default it's the first # devise role declared in your routes. # config.default_scope = :user # Configure sign_out behavior. # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope). # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes. # config.sign_out_all_scopes = false # ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. Default is [:html] # config.navigational_formats = [:html, :iphone] # ==> Warden configuration # If you want to use other strategies, that are not (yet) supported by Devise, # you can configure them inside the config.warden block. The example below # allows you to setup OAuth, using http://github.com/roman/warden_oauth # # config.warden do |manager| # manager.oauth(:twitter) do |twitter| # twitter.consumer_secret = <YOUR CONSUMER SECRET> # twitter.consumer_key = <YOUR CONSUMER KEY> # twitter.options :site => 'http://twitter.com' # end # manager.default_strategies(:scope => :user).unshift :twitter_oauth # end end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/simple_form.rb
config/initializers/simple_form.rb
# Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Components used by the form builder to generate a complete input. You can remove # any of them, change the order, or even add your own components to the stack. # config.components = [ :placeholder, :label_input, :hint, :error ] # Default tag used on hints. # config.hint_tag = :span # CSS class to add to all hint tags. # config.hint_class = :hint # Default tag used on errors. # config.error_class = :error # Default tag used on errors. # config.error_tag = :span # Method used to tidy up errors. # config.error_method = :first # Default tag used for error notification helper. # config.error_notification_tag = :p # CSS class to add for error notification helper. # config.error_notification_class = :error_notification # ID to add for error notification helper. # config.error_notification_id = nil # You can wrap all inputs in a pre-defined tag. # config.wrapper_tag = :div # CSS class to add to all wrapper tags. # config.wrapper_class = :input # CSS class to add to the wrapper if the field has errors. # config.wrapper_error_class = :field_with_errors # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. # config.collection_wrapper_tag = nil # You can wrap each item in a collection of radio/check boxes with a tag, defaulting to none. # config.item_wrapper_tag = nil # Series of attemps to detect a default label method for collection. # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] # Series of attemps to detect a default value method for collection. # config.collection_value_methods = [ :id, :to_s ] # How the label text should be generated altogether with the required text. # config.label_text = lambda { |label, required| "#{required} #{label}" } # Whether attributes are required by default (or not). Default is true. # config.required_by_default = true # Custom mappings for input types. This should be a hash containing a regexp # to match as key, and the input type that will be used when the field name # matches the regexp as value. # config.input_mappings = { /count/ => :integer } # Collection of methods to detect if a file type was given. # config.file_methods = [ :file?, :public_filename ] # Default priority for time_zone inputs. # config.time_zone_priority = nil # Default priority for country inputs. # config.country_priority = nil # Default size for text inputs. # config.default_input_size = 50 # When false, do not use translations for labels, hints or placeholders. # config.translate = true end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/mime_types.rb
config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/initializers/secret_token.rb
config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Snowfinch::Application.config.secret_token = '099d9513241f6f77090b04905eb5438b44c297ae36a822a17e8f1d6eb41e7c2a64ff9fc2052c14757c031d97b457a01cfcbd35130bee66d3ddec0b58159674ab'
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/environments/test.rb
config/environments/test.rb
Snowfinch::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 # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/environments/development.rb
config/environments/development.rb
Snowfinch::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 # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jcxplorer/snowfinch
https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/config/environments/production.rb
config/environments/production.rb
Snowfinch::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true # Specifies the header that your server uses for sending files config.action_dispatch.x_sendfile_header = "X-Sendfile" # For nginx: # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # If you have no front-end server that supports something like X-Sendfile, # just comment this out and Rails will serve the files # See everything in the log (default is :info) # config.log_level = :debug # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Use a different cache store in production # config.cache_store = :mem_cache_store # Disable Rails's static asset server # In production, Apache or nginx will already do this config.serve_static_assets = false # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable threaded mode # config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true # Send deprecation notices to registered listeners config.active_support.deprecation = :notify end
ruby
MIT
ffe6032de2adce64d3bea78cce401e7c9f75b701
2026-01-04T17:48:47.586566Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/init.rb
init.rb
require 'wizardly'
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/image_submit_helper.rb
app/helpers/image_submit_helper.rb
module ImageSubmitHelper def wizardly_submit @@wizardly_submit ||= {} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_submit[step_id] buttons = @wizard.pages[@step].buttons @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[step_id] end def wizardly_image_submit(asset_dir = nil, opts = {}) @@wizardly_image_submit ||={} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_image_submit[step_id] asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/" buttons = @wizard.pages[@step].buttons opts[:name] = 'commit' @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button| opts[:value] = button.name io << image_submit_tag("#{asset_dir}#{button.id}.png", opts) end.string end @@wizardly_image_submit[step_id] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/sandbox_helper.rb
app/helpers/sandbox_helper.rb
module SandboxHelper def wizardly_submit @@wizardly_submit ||= {} unless @@wizardly_submit[@step] buttons = @wizard.pages[@step].buttons @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[@step] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/session_helper.rb
app/helpers/session_helper.rb
module SessionHelper def wizardly_submit @@wizardly_submit ||= {} unless @@wizardly_submit[@step] buttons = @wizard.pages[@step].buttons @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[@step] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/callbacks_helper.rb
app/helpers/callbacks_helper.rb
module CallbacksHelper def wizardly_submit @@wizardly_submit ||= {} unless @@wizardly_submit[@step] buttons = @wizard.pages[@step].buttons @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[@step] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/data_modes_helper.rb
app/helpers/data_modes_helper.rb
module DataModesHelper def wizardly_submit @@wizardly_submit ||= {} unless @@wizardly_submit[@step] buttons = @wizard.pages[@step].buttons @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[@step] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/avatar_session_helper.rb
app/helpers/avatar_session_helper.rb
module AvatarSessionHelper def wizardly_submit @@wizardly_submit ||= {} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_submit[step_id] buttons = @wizard.pages[@step].buttons @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name, :name=>button.id.to_s) end.string end @@wizardly_submit[step_id] end def wizardly_image_submit(asset_dir = nil, opts = {}) @@wizardly_image_submit ||={} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_image_submit[step_id] asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/" buttons = @wizard.pages[@step].buttons @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button| opts[:value] = button.name opts[:name] = button.id.to_s io << image_submit_tag("#{asset_dir}#{button.id}.png", opts) end.string end @@wizardly_image_submit[step_id] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/generated_helper.rb
app/helpers/generated_helper.rb
module GeneratedHelper def wizardly_submit @@wizardly_submit ||= {} unless @@wizardly_submit[@step] buttons = @wizard.pages[@step].buttons @@wizardly_submit[@step] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name) end.string end @@wizardly_submit[@step] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/application_helper.rb
app/helpers/application_helper.rb
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/helpers/scaffold_test_helper.rb
app/helpers/scaffold_test_helper.rb
module ScaffoldTestHelper def wizardly_submit @@wizardly_submit ||= {} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_submit[step_id] buttons = @wizard.pages[@step].buttons @@wizardly_submit[step_id] = buttons.inject(StringIO.new) do |io, button| io << submit_tag(button.name, :name=>button.id.to_s) end.string end @@wizardly_submit[step_id] end def wizardly_image_submit(asset_dir = nil, opts = {}) @@wizardly_image_submit ||={} step_id = "#{controller_name}_#{@step}".to_sym unless @@wizardly_image_submit[step_id] asset_dir = asset_dir ? "#{asset_dir}/".squeeze("/").sub(/^\//,'') : "wizardly/" buttons = @wizard.pages[@step].buttons @@wizardly_image_submit[step_id] = buttons.inject(StringIO.new) do |io, button| opts[:value] = button.name opts[:name] = button.id.to_s io << image_submit_tag("#{asset_dir}#{button.id}.png", opts) end.string end @@wizardly_image_submit[step_id] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/macro_controller.rb
app/controllers/macro_controller.rb
class MacroController < ApplicationController act_wizardly_for :user, :form_data=>:sandbox, :completed=>{:controller=>:main, :action=>:finished}, :canceled=>{:controller=>:main, :action=>:canceled} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/callbacks_module.rb
app/controllers/callbacks_module.rb
module Callbacks # on_errors(:second) do # end # on_get(:second) do # end # on_post(:second) do # end # on_next(:second) do # end # on_cancel(:second) do # end # on_render do # end # on_cancel(:all) do # end def self.action_callbacks [ :_on_get_init_form, :_on_post_init_form, :_on_invalid_init_form, :_on_init_form_next, :_on_init_form_finish, :_on_init_form_back, :_on_init_form_skip, :_on_init_form_cancel, :_on_get_second_porm, :_on_post_init_form, :_on_invalid_init_form, :_on_second_form_back, :_on_second_form_next, :_on_second_form_skip, :_on_second_form_finish, :_on_second_form_cancel, :_on_get_finish_form, :_on_post_finish_form, :_on_invalid_finish_form, :_on_finish_form_back, :_on_finish_form_skip, :_on_finish_form_finish, :_on_finish_form_next, :_on_finish_form_cancel, :wizard_render_form ] end def self.wizard_callbacks [ :_on_wizard_cancel, :_on_wizard_skip, :_on_wizard_back, :_on_wizard_finish ] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/session_controller.rb
app/controllers/session_controller.rb
class SessionController < ApplicationController act_wizardly_for :four_step_user, :redirect=>'/main/index', :form_data=>:session, :skip=>true end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/main_controller.rb
app/controllers/main_controller.rb
class MainController < ApplicationController def index @links = { :macro=>'/macro', :avatar_session=>'/avatar_session', :generated=>'/generated', :scaffold_test=>'/scaffold_test', :callbacks=>'/callbacks', :session=>'/session', :session_init=>'/session/init', :session_second=>'/session/second', :session_third=>'/session/third', :session_finish=>'/session/finish', :sandbox=>'/sandbox', :sandbox_init=>'/sandbox/init', :sandbox_second=>'/sandbox/second', :sandbox_third=>'/sandbox/third', :sandbox_finish=>'/sandbox/finish', :image_submit=>'/image_submit' } end def finished @referring_controller = referring_controller end def canceled @referring_controller = referring_controller end def referrer_page end private def referring_controller referer = request.env['HTTP_REFERER'] ActionController::Routing::Routes.recognize_path(URI.parse(referer).path)[:controller] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/data_modes_controller.rb
app/controllers/data_modes_controller.rb
class DataModesController < ApplicationController act_wizardly_for :user, :persist_model=>:per_page, :form_data=>:session, :completed=>{:controller=>:main, :action=>:finished}, :canceled=>{:controller=>:main, :action=>:canceled} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/scaffold_test_controller.rb
app/controllers/scaffold_test_controller.rb
class ScaffoldTestController < ApplicationController #< WizardForModelController wizard_for_model :user, :skip=>true, :form_data=>:sandbox, :mask_passwords=>[:password, :password_confirmation], :completed=>{:controller=>:main, :action=>:finished}, :canceled=>{:controller=>:main, :action=>:canceled} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/callbacks3_controller.rb
app/controllers/callbacks3_controller.rb
require 'wizardly' class Callbacks3Controller < ApplicationController act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation], :completed=>{:controller=>:main, :action=>:finished}, :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled} on_post(:second) do redirect_to '/main/index#on_post_second_form' end on_post(:init) do @on_post_init_form = true end on_get(:all) do redirect_to '/main/index#on_get_all' end on_errors(:init) do redirect_to '/main/index#on_invalid_init_form' end on_back(:init, :finish) do redirect_to '/main/index#on_init_and_finish_form_back' end on_cancel(:init, :finish) do redirect_to '/main/index#on_init_and_finish_form_cancel' end on_next(:init) do redirect_to '/main/index#on_init_form_next' end on_skip(:init, :finish) do redirect_to '/main/index#on_init_and_finish_form_skip' end on_finish(:finish) do redirect_to '/main/index#on_finish_form_finish' end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/data_modes2_controller.rb
app/controllers/data_modes2_controller.rb
class DataModes2Controller < ApplicationController act_wizardly_for :user, :persist_model=>:per_page, :form_data=>:sandbox, :completed=>{:controller=>:main, :action=>:finished}, :canceled=>{:controller=>:main, :action=>:canceled} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/generated_controller.rb
app/controllers/generated_controller.rb
# # GeneratedController class generated by wizardly_controller # class GeneratedController < ApplicationController before_filter :guard_entry # finish action method def finish begin @step = :finish @wizard = wizard_config @title = 'Finish' @description = '' _build_wizard_model if request.post? && callback_performs_action?(:_on_post_finish_form) raise CallbackError, "render or redirect not allowed in :on_post(:finish) callback", caller end button_id = check_action_for_button return if performed? if request.get? return if callback_performs_action?(:_on_get_finish_form) render_wizard_form return end # @user.enable_validation_group :finish unless @user.valid?(:finish) return if callback_performs_action?(:_on_invalid_finish_form) render_wizard_form return end @do_not_complete = false callback_performs_action?(:_on_finish_form_finish) complete_wizard unless @do_not_complete ensure _preserve_wizard_model end end # init action method def init begin @step = :init @wizard = wizard_config @title = 'Init' @description = '' _build_wizard_model if request.post? && callback_performs_action?(:_on_post_init_form) raise CallbackError, "render or redirect not allowed in :on_post(:init) callback", caller end button_id = check_action_for_button return if performed? if request.get? return if callback_performs_action?(:_on_get_init_form) render_wizard_form return end # @user.enable_validation_group :init unless @user.valid?(:init) return if callback_performs_action?(:_on_invalid_init_form) render_wizard_form return end @do_not_complete = false if button_id == :finish callback_performs_action?(:_on_init_form_finish) complete_wizard unless @do_not_complete return end return if callback_performs_action?(:_on_init_form_next) redirect_to :action=>:second ensure _preserve_wizard_model end end # second action method def second begin @step = :second @wizard = wizard_config @title = 'Second' @description = '' _build_wizard_model if request.post? && callback_performs_action?(:_on_post_second_form) raise CallbackError, "render or redirect not allowed in :on_post(:second) callback", caller end button_id = check_action_for_button return if performed? if request.get? return if callback_performs_action?(:_on_get_second_form) render_wizard_form return end # @user.enable_validation_group :second unless @user.valid?(:second) return if callback_performs_action?(:_on_invalid_second_form) render_wizard_form return end @do_not_complete = false if button_id == :finish callback_performs_action?(:_on_second_form_finish) complete_wizard unless @do_not_complete return end return if callback_performs_action?(:_on_second_form_next) redirect_to :action=>:finish ensure _preserve_wizard_model end end def index redirect_to :action=>:init end protected def _on_wizard_finish return if @wizard_completed_flag @user.save_without_validation! if @user.changed? @wizard_completed_flag = true reset_wizard_form_data _wizard_final_redirect_to(:completed) end def _on_wizard_skip self.progression = self.progression - [@step] redirect_to(:action=>wizard_config.next_page(@step)) unless self.performed? end def _on_wizard_back redirect_to(:action=>(previous_in_progression_from(@step) || :init)) unless self.performed? end def _on_wizard_cancel _wizard_final_redirect_to(:canceled) end def _wizard_final_redirect_to(type) init = (type == :canceled && wizard_config.form_data_keep_in_session?) ? self.initial_referer : reset_wizard_session_vars unless self.performed? redir = (type == :canceled ? wizard_config.canceled_redirect : wizard_config.completed_redirect) || init return redirect_to(redir) if redir raise Wizardly::RedirectNotDefinedError, "No redirect was defined for completion or canceling the wizard. Use :completed and :canceled options to define redirects.", caller end end hide_action :_on_wizard_finish, :_on_wizard_skip, :_on_wizard_back, :_on_wizard_cancel, :_wizard_final_redirect_to protected def do_not_complete; @do_not_complete = true; end def previous_in_progression_from(step) po = [:init, :second, :finish] p = self.progression p -= po[po.index(step)..-1] self.progression = p p.last end def check_progression p = self.progression a = params[:action].to_sym return if p.last == a po = [:init, :second, :finish] return unless (ai = po.index(a)) p -= po[ai..-1] p << a self.progression = p end # for :form_data=>:session def guard_entry if (r = request.env['HTTP_REFERER']) begin h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get}) rescue else return check_progression if (h[:controller]||'') == 'generated' self.initial_referer = h unless self.initial_referer end end # coming from outside the controller or no route for GET if (params[:action] == 'init' || params[:action] == 'index') return check_progression elsif self.wizard_form_data p = self.progression return check_progression if p.include?(params[:action].to_sym) return redirect_to(:action=>(p.last||:init)) end redirect_to :action=>:init end hide_action :guard_entry def render_and_return return if callback_performs_action?('_on_get_'+@step.to_s+'_form') render_wizard_form render unless self.performed? end def complete_wizard(redirect = nil) unless @wizard_completed_flag @user.save_without_validation! callback_performs_action?(:_after_wizard_save) end redirect_to redirect if (redirect && !self.performed?) return if @wizard_completed_flag _on_wizard_finish redirect_to('/main/finished') unless self.performed? end def _build_wizard_model if self.wizard_config.persist_model_per_page? h = self.wizard_form_data if (h && model_id = h['id']) _model = User.find(model_id) _model.attributes = params[:user]||{} @user = _model return end @user = User.new(params[:user]) else # persist data in session or flash h = (self.wizard_form_data||{}).merge(params[:user] || {}) @user = User.new(h) end end def _preserve_wizard_model return unless (@user && !@wizard_completed_flag) if self.wizard_config.persist_model_per_page? @user.save_without_validation! if request.get? @user.errors.clear else @user.reject_non_validation_group_errors end self.wizard_form_data = {'id'=>@user.id} else self.wizard_form_data = @user.attributes end end hide_action :_build_wizard_model, :_preserve_wizard_model def initial_referer session[:generated_irk] end def initial_referer=(val) session[:generated_irk] = val end def progression=(array) session[:generated_prg] = array end def progression session[:generated_prg]||[] end hide_action :progression, :progression=, :initial_referer, :initial_referer= def wizard_form_data=(hash) if wizard_config.form_data_keep_in_session? session[:generated_dat] = hash else if hash flash[:generated_dat] = hash else flash.discard(:generated_dat) end end end def reset_wizard_form_data; self.wizard_form_data = nil; end def wizard_form_data wizard_config.form_data_keep_in_session? ? session[:generated_dat] : flash[:generated_dat] end hide_action :wizard_form_data, :wizard_form_data=, :reset_wizard_form_data def render_wizard_form end hide_action :render_wizard_form def performed?; super; end hide_action :performed? def underscore_button_name(value) value.to_s.strip.squeeze(' ').gsub(/ /, '_').downcase end hide_action :underscore_button_name def reset_wizard_session_vars self.progression = nil init = self.initial_referer self.initial_referer = nil init end hide_action :reset_wizard_session_vars def check_action_for_button button_id = nil case when params[:commit] button_name = params[:commit] button_id = underscore_button_name(button_name).to_sym when ((b_ar = self.wizard_config.buttons.find{|k,b| params[k]}) && params[b_ar.first] == b_ar.last.name) button_name = b_ar.last.name button_id = b_ar.first end if button_id unless [:next, :finish].include?(button_id) action_method_name = "_on_" + params[:action].to_s + "_form_" + button_id.to_s callback_performs_action?(action_method_name) unless ((btn_obj = self.wizard_config.buttons[button_id]) == nil || btn_obj.user_defined?) method_name = "_on_wizard_" + button_id.to_s if (self.method(method_name)) self.__send__(method_name) else raise MissingCallbackError, "Callback method either '" + action_method_name + "' or '" + method_name + "' not defined", caller end end end end button_id end hide_action :check_action_for_button @wizard_callbacks ||= [] def self.wizard_callbacks; @wizard_callbacks; end def callback_performs_action?(methId) cache = self.class.wizard_callbacks return false if cache.include?(methId) if self.respond_to?(methId, true) self.send(methId) else cache << methId return false end self.performed? end hide_action :callback_performs_action? def self.on_post(*args, &block) self._define_action_callback_macro('on_post', '_on_post_%s_form', *args, &block) end def self.on_get(*args, &block) self._define_action_callback_macro('on_get', '_on_get_%s_form', *args, &block) end def self.on_errors(*args, &block) self._define_action_callback_macro('on_errors', '_on_invalid_%s_form', *args, &block) end def self.on_finish(*args, &block) self._define_action_callback_macro('on_finish', '_on_%s_form_finish', *args, &block) end def self.on_skip(*args, &block) self._define_action_callback_macro('on_skip', '_on_%s_form_skip', *args, &block) end def self.on_next(*args, &block) self._define_action_callback_macro('on_next', '_on_%s_form_next', *args, &block) end def self.on_back(*args, &block) self._define_action_callback_macro('on_back', '_on_%s_form_back', *args, &block) end def self.on_cancel(*args, &block) self._define_action_callback_macro('on_cancel', '_on_%s_form_cancel', *args, &block) end def self._define_action_callback_macro(macro_first, macro_last, *args, &block) return if args.empty? all_forms = [:init, :second, :finish] if args.include?(:all) forms = all_forms else forms = args.map do |fa| unless all_forms.include?(fa) raise(ArgumentError, ":"+fa.to_s+" in callback '" + macro_first + "' is not a form defined for the wizard", caller) end fa end end forms.each do |form| self.send(:define_method, sprintf(macro_last, form.to_s), &block ) hide_action macro_last.to_sym end end def self.on_completed(&block) self.send(:define_method, :_after_wizard_save, &block ) end public def wizard_config; self.class.wizard_config; end hide_action :wizard_config private def self.wizard_config; @wizard_config; end @wizard_config = Wizardly::Wizard::Configuration.create(:generated, :user, :allow_skip=>true) do when_completed_redirect_to '/main/finished' when_canceled_redirect_to '/main/canceled' # other things you can configure # change_button(:next).to('Next One') # change_button(:back).to('Previous') # create_button('Help') # set_page(:init).buttons_to :next_one, :previous, :cancel, :help #this removes skip end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/avatar_session_controller.rb
app/controllers/avatar_session_controller.rb
require 'wizardly' class AvatarSessionController < ApplicationController #tests paperclip act_wizardly_for :user_avatar, :form_data=>:session, :persist_model=>:per_page, :completed=>{:controller=>:main, :action=>:finished}, :canceled=>{:controller=>:main, :action=>:canceled} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/callbacks_controller.rb
app/controllers/callbacks_controller.rb
require 'wizardly' class CallbacksController < ApplicationController require 'callbacks_module' act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation], :completed=>{:controller=>:main, :action=>:finished}, :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled} def flag(val) instance_variable_set("@#{val}", true) #puts "--<<#{val}>>--" end def self.flag_callback(name) self.class_eval "def #{name}; flag :#{name}; end " end def self.chain_callback(name) self.class_eval <<-ERT alias_method :#{name}_orig, :#{name} def #{name}; flag :#{name}; #{name}_orig; end ERT end Callbacks::action_callbacks.each {|cb| flag_callback cb } # def on_invalid_finish_form # flag :on_finish_page_errors # @user[:password] = '' # @user[:password_confirmation] = '' # end Callbacks::wizard_callbacks.each {|cb| chain_callback cb} end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/sandbox_controller.rb
app/controllers/sandbox_controller.rb
class SandboxController < ApplicationController act_wizardly_for :four_step_user, :redirect=>'/main/index', :form_data=>:sandbox, :skip=>true end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/application_controller.rb
app/controllers/application_controller.rb
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryProtection for details # Scrub sensitive parameters from your log # filter_parameter_logging :password end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/callbacks2_controller.rb
app/controllers/callbacks2_controller.rb
require 'wizardly' class Callbacks2Controller < ApplicationController act_wizardly_for :user, :skip=>true, :guard=>false, :mask_passwords=>[:password, :password_confirmation], :completed=>{:controller=>:main, :action=>:finished}, :canceled=>'/main/canceled'#{:controller=>:main, :action=>:canceled} #NOTE: these only for testing - the preferred method of defining callbacks is # using the callback macros -- see Callbacks3Controller and the Readme.rdoc ;) def _on_post_second_form redirect_to '/main/index#on_post_second_form' end def _on_get_init_form redirect_to '/main/index#on_get_init_form' end def _on_invalid_init_form redirect_to '/main/index#on_invalid_init_form' end def _on_init_form_back redirect_to '/main/index#on_init_form_back' end def _on_init_form_cancel redirect_to '/main/index#on_init_form_cancel' end def _on_init_form_next redirect_to '/main/index#on_init_form_next' end def _on_init_form_skip redirect_to '/main/index#on_init_form_skip' end def _on_finish_form_finish redirect_to '/main/index#on_finish_form_finish' end hide_action :_on_post_second_form hide_action :_on_get_init_form hide_action :_on_invalid_init_form hide_action :_on_init_form_back hide_action :_on_init_form_cancel hide_action :_on_init_form_next hide_action :_on_init_form_skip hide_action :_on_finish_form_finish end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/controllers/image_submit_controller.rb
app/controllers/image_submit_controller.rb
class ImageSubmitController < ApplicationController wizard_for_model :user, :redirect=>'/main/index', :skip=>true end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/models/user_avatar.rb
app/models/user_avatar.rb
class UserAvatar < User has_attached_file :avatar validates_attachment_presence :avatar validation_group :init, :fields=>[:first_name, :last_name] validation_group :second, :fields=>[:age, :gender, :programmer, :status, :avatar] validation_group :finish, :fields=>[:username, :password, :password_confirmation] end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/models/four_step_user.rb
app/models/four_step_user.rb
require 'validation_group' class FourStepUser < User validation_group :init, :fields=>[:first_name, :last_name] validation_group :second, :fields=>[:age, :gender] validation_group :third, :fields=>[:programmer, :status] validation_group :finish, :fields=>[:username, :password, :password_confirmation] end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/app/models/user.rb
app/models/user.rb
#require 'validation_group' class User < ActiveRecord::Base =begin t.string :first_name t.string :last_name t.string :username t.string :password t.integer :age t.string :gender t.boolean :programmer t.string :status =end validates_confirmation_of :password validates_presence_of :first_name, :last_name, :username, :password, :age, :gender, :status #validates_numercality_of :age #validates_uniqueness_of :username validation_group :init, :fields=>[:first_name, :last_name] validation_group :second, :fields=>[:age, :gender, :programmer, :status] validation_group :finish, :fields=>[:username, :password, :password_confirmation] end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/db/schema.rb
db/schema.rb
# This file is auto-generated from the current state of the database. Instead of editing this file, # please use the migrations feature of Active Record to incrementally modify your database, and # then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your database schema. If you need # to create the application database on another system, you should be using db:schema:load, not running # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended to check this file into your version control system. ActiveRecord::Schema.define(:version => 20090718172749) do create_table "sessions", :force => true do |t| t.string "session_id", :null => false t.text "data" t.datetime "created_at" t.datetime "updated_at" end add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" create_table "users", :force => true do |t| t.string "first_name" t.string "last_name" t.string "username" t.string "password" t.integer "age" t.string "gender" t.boolean "programmer" t.string "status" t.string "avatar_file_name" t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "created_at" t.datetime "updated_at" end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/db/migrate/20090718171255_create_sessions.rb
db/migrate/20090718171255_create_sessions.rb
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.string :session_id, :null => false t.text :data t.timestamps end add_index :sessions, :session_id add_index :sessions, :updated_at end def self.down drop_table :sessions end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/db/migrate/20090718172749_create_users.rb
db/migrate/20090718172749_create_users.rb
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :first_name t.string :last_name t.string :username t.string :password t.integer :age t.string :gender t.boolean :programmer t.string :status t.string :avatar_file_name t.string :avatar_content_type t.integer :avatar_file_size t.timestamps end end def self.down drop_table :users end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/test_helper.rb
test/test_helper.rb
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase # Transactional fixtures accelerate your tests by wrapping each test method in # a transaction that's rolled back on completion. This ensures that the test # database remains unchanged so your fixtures don't have to be reloaded # between every test method. Fewer database queries means faster tests. # # Read Mike Clark's excellent walkthrough at # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting # # Every Active Record database supports transactions except MyISAM tables in # MySQL. Turn off transactional fixtures in this case; however, if you don't # care one way or the other, switching from MyISAM to InnoDB tables is # recommended. # # The only drawback to using transactional fixtures is when you actually need # to test transactions. Since your test is bracketed by a transaction, any # transactions started in your code will be automatically rolled back. self.use_transactional_fixtures = true # Instantiated fixtures are slow, but give you @david where otherwise you # would need people(:david). If you don't want to migrate your existing test # cases which use the @david style and don't mind the speed hit (each # instantiated fixtures translates to a database query per test method), then # set this back to true. self.use_instantiated_fixtures = false # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in # alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in # integration tests -- they do not yet inherit this setting fixtures :all # Add more helper methods to be used by all tests here... end Webrat.configure do |config| config.mode = :rails end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/performance/browsing_test.rb
test/performance/browsing_test.rb
require 'test_helper' require 'performance_test_help' # Profiling results for each test method are written to tmp/performance. class BrowsingTest < ActionController::PerformanceTest def test_homepage get '/' end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/unit/user_test.rb
test/unit/user_test.rb
require 'test_helper' class UserTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/unit/helpers/image_submit_helper_test.rb
test/unit/helpers/image_submit_helper_test.rb
require 'test_helper' class ImageSubmitHelperTest < ActionView::TestCase end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/unit/helpers/callbacks_helper_test.rb
test/unit/helpers/callbacks_helper_test.rb
require 'test_helper' class CallbacksHelperTest < ActionView::TestCase end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/functional/callbacks_controller_test.rb
test/functional/callbacks_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper' module TestVariables def init_page; "init"; end def second_page; "second"; end def third_page; "third"; end def finish_page; "finish"; end def blank_error; "*can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/callbacks/index'; end def finish_page_path; '/callbacks/finish'; end def second_page_path; '/callbacks/second'; end def third_page_path; '/callbacks/third'; end def init_page_path; '/callbacks/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end class CallbacksControllerTest < ActionController::TestCase include TestVariables # def test_should_flag_on_get_init_page_when_calling_get_on_init_action # get init_page # assert_response :success # assert assigns['on_get_init_page'] # end # def test_should_flag_on_init_page_errors_when_clicking_next_on_init_page_with_empty_fields # post init_page, :commit=>next_button # assert_template init_page # assert assigns['on_init_page_errors'] # end def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next #assert_redirected_to :action=>second_page assert assigns['on_init_page_next'] end # def test_should_flag_ON_INIT_PAGE_SKIP_when_clicking_skip_on_init_page # post init_page, :commit=>skip_button # assert_redirected_to :action=>second_page # assert assigns['on_init_page_skip'] # end # def test_should_flag_ON_SECOND_PAGE_BACK_when_clicking_back_from_second_page # post init_page, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>next_button # #assert_redirected_to :action=>second_page # post second_page, :user=>{:age=>field_age.to_s, :gender=>field_gender}, :commit=>back_button # #assert_redirected_to :action=>init_page # assert assigns['on_second_page_back'] # end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/test/functional/image_submit_controller_test.rb
test/functional/image_submit_controller_test.rb
require 'test_helper' class ImageSubmitControllerTest < ActionController::TestCase # Replace this with your real tests. test "the truth" do assert true end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/spec_helper.rb
spec/spec_helper.rb
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) #require 'validation_group' #require 'wizardly' require 'spec/autorun' require 'spec/rails' require 'spec/integrations/shared_examples' require 'spec/integrations/matchers' Webrat.configure do |config| config.mode = :rails end Spec::Runner.configure do |config| # If you're not using ActiveRecord you should remove these # lines, delete config/database.yml and disable :active_record # in your config/boot.rb # config.use_transactional_fixtures = true # config.use_instantiated_fixtures = false # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' end #setup for integrating webrat with rspec module Spec::Rails::Example class IntegrationExampleGroup < ActionController::IntegrationTest def initialize(defined_description, options={}, &implementation) defined_description.instance_eval do def to_s self end end super(defined_description) end Spec::Example::ExampleGroupFactory.register(:integration, self) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/generated_spec.rb
spec/integrations/generated_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'step_helpers' #require 'rails_generator' #require 'rails_generator/scripts/generate' # #gen_argv = [] #gen_argv << "wizardly_controller" << "generated" << "user" << "/main/finished" << "/main/canceled" << "--force" #Rails::Generator::Scripts::Generate.new.run(gen_argv) #load 'app/controllers/generated_controller.rb' module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/generated/index'; end def finish_page_path; '/generated/finish'; end def second_page_path; '/generated/second'; end def init_page_path; '/generated/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end describe "GeneratedController" do include TestVariables include StepHelpers it_should_behave_like "form data using session" it_should_behave_like "all implementations" end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/matchers.rb
spec/integrations/matchers.rb
#defines custom rspec matcher for this test Spec::Matchers.define :be_blank do match do |value| value == nil || value == '' end end Spec::Matchers.define :be_nil do match do |value| value == nil end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/macro_spec.rb
spec/integrations/macro_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/macro/index'; end def finish_page_path; '/macro/finish'; end def second_page_path; '/macro/second'; end def init_page_path; '/macro/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end describe "MacroController" do include TestVariables include StepHelpers it_should_behave_like "form data using sandbox" it_should_behave_like "all implementations" end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/avatar_spec.rb
spec/integrations/avatar_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'avatar_step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def field_avatar; File.dirname(__FILE__) + '/../../public/images/avatar.png'; end; def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end describe "AvatarSessionController" do include TestVariables include AvatarStepHelpers def index_page_path; '/avatar_session/index'; end def finish_page_path; '/avatar_session/finish'; end def second_page_path; '/avatar_session/second'; end def init_page_path; '/avatar_session/init'; end it "should accept avatar field" do step_to_second_page fill_in_second_page click_button next_button end it "should accept and save avatar field" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button u = AvatarUser.find_by_username(field_username) u.should_not be_nil u.first_name.should == field_first_name u.avatar_file_name.should include('avatar.png') u.avatar_file_size.should_not == 0 u.avatar_content_type.should == 'image/png' end it "should not reset form data when leaving wizard and returning" do step_to_finish_page click_button cancel_button click_link 'signup' current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name click_button next_button field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender field_with_id(/programmer/).value.should == (field_programmer ? "1":"0") field_with_id(/status/).value.should == field_status end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/session_spec.rb
spec/integrations/session_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'four_step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def third_page; "third"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/session/index'; end def finish_page_path; '/session/finish'; end def second_page_path; '/session/second'; end def init_page_path; '/session/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end #testing :form_data=>:sandbox describe "SessionController" do include TestVariables include FourStepHelpers it "should return to last page in progression when leaving and trying to return to lager page in othe order" do step_to_second_page fill_in_second_page click_button cancel_button current_url.should include('main') click_link 'session_finish' current_url.should include(second_page) field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender end it "should clear all session variables including fields, progression when finishing and trying to return to page other than first" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button (u = User.find(:first)).should_not be_nil u.first_name.should == field_first_name u.last_name.should == field_last_name u.age.should == field_age u.gender.should == field_gender u.programmer.should == field_programmer u.status.should == field_status u.username.should == field_username u.password.should == field_password current_url.should include('main') click_link 'session_third' current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, navigate with link and return to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button click_link 'session' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in first page, leave and navigate with link to first page with same fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button click_link 'session_init' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in first page, post, leave and return to first page with same fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button next_button current_url.should include(second_page) click_button cancel_button current_url.should include('main') click_link 'session_init' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in second page, post, leave and return to second when trying to return to navigate by link to second page" do step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/gender/).value.should be_blank fill_in_second_page click_button next_button current_url.should include(third_page) click_button cancel_button current_url.should include('main') click_link 'session_second' #visit second_page_path current_url.should include(second_page) field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender end it "should fill in first page, navigate with url and return to first page with same fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in first page, leave and navigate with url to first page with same fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button visit init_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in first page, post, leave and navigate with url to first page with same fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button next_button current_url.should include(second_page) click_button cancel_button current_url.should include('main') visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in second page, post, leave and navigate with url to init when trying to return to second page" do step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/gender/).value.should be_blank fill_in_second_page click_button next_button current_url.should include(third_page) click_button cancel_button current_url.should include('main') visit second_page_path current_url.should include(second_page) field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender end it "should skip first page and return to first page when back clicked on second page" do step_to_init_page fill_in_init_page click_button skip_button current_url.should include(second_page) click_button back_button current_url.should include(init_page) #field_with_id(/first/).value.should be_blank #field_with_id(/last/).value.should be_blank end it "should skip the second page and return to init page when back clicked on third page" do step_to_second_page fill_in_second_page click_button skip_button current_url.should include(third_page) click_button back_button current_url.should include(init_page) end it "should skip both init and second page and return to init page when back clicked on third page" do step_to_init_page click_button skip_button current_url.should include(second_page) click_button skip_button current_url.should include(third_page) click_button back_button current_url.should include(init_page) end it "should skip third and return to second when back pressed on finish page" do step_to_third_page current_url.should include(third_page) click_button skip_button current_url.should include(finish_page) click_button back_button current_url.should include(second_page) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/scaffold_test_spec.rb
spec/integrations/scaffold_test_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'step_helpers' require 'rails_generator' require 'rails_generator/scripts/generate' scaf_argv = [] scaf_argv << "wizardly_scaffold" << "scaffold_test" << "--force" Rails::Generator::Scripts::Generate.new.run(scaf_argv) module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/scaffold_test/index'; end def finish_page_path; '/scaffold_test/finish'; end def second_page_path; '/scaffold_test/second'; end def init_page_path; '/scaffold_test/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end describe "ScaffoldTestController" do include TestVariables include StepHelpers it_should_behave_like "form data using sandbox" it_should_behave_like "all implementations" end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/data_modes2_spec.rb
spec/integrations/data_modes2_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/data_modes2/index'; end def finish_page_path; '/data_modes2/finish'; end def second_page_path; '/data_modes2/second'; end def init_page_path; '/data_modes2/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end #testing :persist_model=>:per_page, :form_data=>:sandbox describe "DataModes2Controller" do include TestVariables include StepHelpers it "should save model incrementally" do User.delete_all step_to_finish_page u = User.find(:first) assert u u.first_name.should == field_first_name u.last_name.should == field_last_name step_to_finish_page v = User.find(:first) assert v v.first_name.should == field_first_name v.last_name.should == field_last_name v.age.should == field_age v.status.should == field_status v.programmer.should == field_programmer v.gender.should == field_gender w = User.find(:all) w.size.should == 1 end it "should complete wizard, save model, and create new model next time" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button u = User.find(:first) assert u u.first_name.should == field_first_name u.password.should == field_password step_to_second_page w = User.find(:all) w.size.should == 2 w.first.id.should_not == w.last.id end it "should fill in first page, leave and return to first page" do User.delete_all step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button visit init_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in second page, leave and return to init page when trying to return to second page directly" do User.delete_all step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/status/).value.should be_blank fill_in_second_page click_button cancel_button visit '/data_modes/'+ second_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank click_button next_button end it_should_behave_like "form data using sandbox" it_should_behave_like "all implementations" end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/shared_examples.rb
spec/integrations/shared_examples.rb
shared_examples_for "form data using sandbox" do it "should reset form data when leaving wizard and returning" do step_to_finish_page click_button cancel_button click_link 'signup' current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end end shared_examples_for "form data using session" do it "should not reset form data when leaving wizard and returning" do step_to_finish_page click_button cancel_button click_link 'signup' current_url.should include(init_page) field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name click_button next_button field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender field_with_id(/programmer/).value.should == (field_programmer ? "1":"0") field_with_id(/status/).value.should == field_status end end shared_examples_for "all implementations" do it "should save user when clicking finish on finish page" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button current_url.should include(main_finished_path) (u = User.find(:first)).should_not be_nil u.first_name.should == field_first_name u.last_name.should == field_last_name u.age.should == field_age u.gender.should == field_gender u.programmer.should == field_programmer u.status.should == field_status u.username.should == field_username u.password.should == field_password end it "should back up to second page from finish page and maintain field data when back button clicked" do step_to_finish_page click_button back_button current_url.should include(second_page) field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender field_with_id(/programmer/).value.should == (field_programmer ? "1":"0") field_with_id(/status/).value.should == field_status end it "should back up to init from second page and maintain field data when back button clicked" do step_to_second_page click_button back_button field_with_id(/first_name/).value.should == field_first_name field_with_id(/last_name/).value.should == field_last_name end it "should maintain field data after backing up then returning to page via next button" do step_to_second_page fill_in(/age/, :with=>field_age) fill_in(/gender/, :with=>field_gender) fill_in(/programmer/, :with=>'') fill_in(/status/, :with=>'') click_button back_button current_url.should include(init_page) click_button next_button field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender field_with_id(/programmer/).value.should be_blank field_with_id(/status/).value.should be_blank end it "should redirect to referrer page when coming from referrer and cancelled from init page" do end it "should redirect to ..main/canceled when clicking cancel button on second page" do step_to_second_page click_button cancel_button current_url.should include(main_canceled_path) end it "should redirect to ..main/canceled when clicking cancel button on finish page" do step_to_finish_page click_button cancel_button current_url.should include(main_canceled_path) end it "should redirect to ..main/canceled when clicking cancel button on init page" do step_to_init_page click_button cancel_button current_url.should include(main_canceled_path) end it "should invalidate finish page with empty fields" do step_to_finish_page click_button finish_button current_url.should include(finish_page) response.body.should contain(blank_error) end it "should invalidate second page with empty fields" do step_to_second_page click_button next_button current_url.should include(second_page) response.body.should contain(blank_error) end it "should invalidate init page with empty fields" do visit init_page_path click_button next_button current_url.should include(init_page) response.body.should include(blank_error) end it "should redirect to init page if entering from finish page" do visit finish_page_path current_url.should include(init_page) end it "should redirect to init page if entering from second page" do visit second_page_path current_url.should include(init_page) end it "should start at init page and fields should be empty when entering from index" do visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should navigate from init to second screen on next button without validation errors" do User.delete_all step_to_second_page current_url.should include(second_page) end it "should go from init to finish screen on next buttons without validation errors" do User.delete_all step_to_finish_page current_url.should include(finish_page) end it "should complete form and save User object on completion without validation errors" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button current_url.should include(main_finished_path) User.find_by_username(field_username).should_not be_nil end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/step_helpers.rb
spec/integrations/step_helpers.rb
module StepHelpers def step_to_init_page visit init_page_path end def fill_in_init_page fill_in(/first_name/, :with=>field_first_name) fill_in(/last_name/, :with=>field_last_name) end def step_to_second_page step_to_init_page fill_in_init_page click_button next_button end def fill_in_second_page fill_in(/age/, :with=>field_age) fill_in(/gender/, :with=>field_gender) fill_in(/status/, :with=>field_status) fill_in(/programmer/, :with=>field_programmer) end def step_to_finish_page step_to_second_page fill_in_second_page click_button next_button end def fill_in_finish_page fill_in(/username/, :with=>field_username) fill_in("user[password]", :with=>field_password) fill_in("user[password_confirmation]", :with=>field_password_confirmation) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/four_step_helpers.rb
spec/integrations/four_step_helpers.rb
module FourStepHelpers def step_to_init_page visit init_page_path end def fill_in_init_page fill_in(/first_name/, :with=>field_first_name) fill_in(/last_name/, :with=>field_last_name) end def step_to_second_page step_to_init_page fill_in_init_page click_button next_button end def fill_in_second_page fill_in(/age/, :with=>field_age) fill_in(/gender/, :with=>field_gender) end def step_to_third_page step_to_second_page fill_in_second_page click_button next_button end def fill_in_third_page fill_in(/status/, :with=>field_status) fill_in(/programmer/, :with=>field_programmer) end def step_to_finish_page step_to_third_page fill_in_third_page click_button next_button end def fill_in_finish_page fill_in(/username/, :with=>field_username) fill_in(/user_password/, :with=>field_password) fill_in(/user_password_confirmation/, :with=>field_password_confirmation) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/data_modes_spec.rb
spec/integrations/data_modes_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/data_modes/index'; end def finish_page_path; '/data_modes/finish'; end def second_page_path; '/data_modes/second'; end def init_page_path; '/data_modes/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end #testing :persist_model=>:per_page, :form_data=>:session describe "DataModesController" do include TestVariables include StepHelpers it "should save model incrementally" do User.delete_all step_to_finish_page u = User.find(:first) assert u u.first_name.should == field_first_name u.last_name.should == field_last_name step_to_finish_page v = User.find(:first) assert v v.first_name.should == field_first_name v.last_name.should == field_last_name v.age.should == field_age v.status.should == field_status v.programmer.should == field_programmer v.gender.should == field_gender w = User.find(:all) w.size.should == 1 end it "should complete wizard, save model, and create new model next time" do User.delete_all step_to_finish_page fill_in_finish_page click_button finish_button u = User.find(:first) assert u u.first_name.should == field_first_name u.password.should == field_password step_to_second_page w = User.find(:all) w.size.should == 2 w.first.id.should_not == w.last.id end it "should fill in first page, leave and return to first page" do User.delete_all step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button step_to_init_page field_with_id(/first/).value.should == field_first_name field_with_id(/last/).value.should == field_last_name end it "should fill in second page, leave and return to second page directly" do User.delete_all step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/status/).value.should be_blank fill_in_second_page click_button cancel_button visit '/data_modes/'+ second_page current_url.should include(second_page) field_with_id(/age/).value.should == field_age.to_s field_with_id(/gender/).value.should == field_gender field_with_id(/programmer/).value.should == (field_programmer ? "1":"0") field_with_id(/status/).value.should == field_status click_button next_button end it_should_behave_like "form data using session" it_should_behave_like "all implementations" end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/avatar_step_helpers.rb
spec/integrations/avatar_step_helpers.rb
module AvatarStepHelpers def step_to_init_page visit init_page_path end def fill_in_init_page fill_in(/first_name/, :with=>field_first_name) fill_in(/last_name/, :with=>field_last_name) end def step_to_second_page step_to_init_page fill_in_init_page click_button next_button end def fill_in_second_page fill_in(/age/, :with=>field_age) fill_in(/gender/, :with=>field_gender) fill_in(/status/, :with=>field_status) fill_in(/programmer/, :with=>field_programmer) fill_in(/avatar/, :with=>field_avatar) end def step_to_finish_page step_to_second_page fill_in_second_page click_button next_button end def fill_in_finish_page fill_in(/username/, :with=>field_username) fill_in("user[password]", :with=>field_password) fill_in("user[password_confirmation]", :with=>field_password_confirmation) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/integrations/sandbox_spec.rb
spec/integrations/sandbox_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require 'four_step_helpers' module TestVariables def init_page; "init"; end def second_page; "second"; end def third_page; "third"; end def finish_page; "finish"; end def blank_error; "can't be blank"; end def back_button; "back"; end def next_button; "next"; end def skip_button; "skip"; end def finish_button; "finish"; end def cancel_button; "cancel"; end def field_first_name; "john"; end def field_last_name; "doe"; end def field_age; 30; end def field_programmer; true; end def field_status; "active"; end def field_gender; "male"; end def field_password; "password"; end def field_password_confirmation; field_password; end def field_username; "johndoe"; end def index_page_path; '/sandbox/index'; end def finish_page_path; '/sandbox/finish'; end def second_page_path; '/sandbox/second'; end def init_page_path; '/sandbox/init'; end def main_finished_path; '/main/finished'; end def main_canceled_path; '/main/canceled'; end end #testing :form_data=>:sandbox describe "SandboxController" do include TestVariables include FourStepHelpers it "should fill in first page, navigate with link and return to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button click_link 'sandbox' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, leave and navigate with link to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button click_link 'sandbox' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, post, leave and navigate with link to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button next_button current_url.should include(second_page) click_button cancel_button current_url.should include('main') click_link 'sandbox' #visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in second page, post, leave and navigate with link to init when trying to return to second page" do step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/gender/).value.should be_blank fill_in_second_page click_button next_button current_url.should include(third_page) click_button cancel_button current_url.should include('main') click_link 'sandbox_second' #visit second_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, navigate with url and return to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, leave and navigate with url to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button cancel_button visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in first page, post, leave and navigate with url to first page with empty fields" do step_to_init_page current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank fill_in_init_page click_button next_button current_url.should include(second_page) click_button cancel_button current_url.should include('main') visit index_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should fill in second page, post, leave and navigate with url to init when trying to return to second page" do step_to_second_page current_url.should include(second_page) field_with_id(/age/).value.should be_blank field_with_id(/gender/).value.should be_blank fill_in_second_page click_button next_button current_url.should include(third_page) click_button cancel_button current_url.should include('main') visit second_page_path current_url.should include(init_page) field_with_id(/first/).value.should be_blank field_with_id(/last/).value.should be_blank end it "should skip first page and return to first page when back clicked on second page" do step_to_init_page fill_in_init_page click_button skip_button current_url.should include(second_page) click_button back_button current_url.should include(init_page) #field_with_id(/first/).value.should be_blank #field_with_id(/last/).value.should be_blank end it "should skip the second page and return to init page when back clicked on third page" do step_to_second_page fill_in_second_page click_button skip_button current_url.should include(third_page) click_button back_button current_url.should include(init_page) end it "should skip both init and second page and return to init page when back clicked on third page" do step_to_init_page click_button skip_button current_url.should include(second_page) click_button skip_button current_url.should include(third_page) click_button back_button current_url.should include(init_page) end it "should skip third and return to second when back pressed on finish page" do step_to_third_page current_url.should include(third_page) click_button skip_button current_url.should include(finish_page) click_button back_button current_url.should include(second_page) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/controllers/callbacks_spec.rb
spec/controllers/callbacks_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/../../app/controllers/callbacks_module' #include Callbacks Spec::Matchers.define :have_callback do |*expected_callbacks| match do |value| Callbacks::action_callbacks.each do |b| value[b] == (expected_callbacks.include?(b) ? true : nil) end Callbacks::wizard_callbacks.each do |w| value[w] == (expected_callbacks.include?(w) ? true : nil) end true end end describe CallbacksController do it "should flag callbacks and render when requesting the init form" do get :init assigns.should have_callback(:on_get_init_form, :render_wizard_form) end it "should flag callbacks and re-render when posting next to the init page with empty fields" do post :init assigns.should have_callback(:on_post_init_form, :on_invalid_init_form, :render_wizard_form) end #should there be a _on_wizard_next it "should flag callbacks when posting next to the init page with valid fields" do post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}} response.should redirect_to(:action=>:second) assigns.should have_callback(:on_post_init_form, :on_init_form_next) end it "should flag callbacks and redirect to :second page when posting skip to init page" do post :init, {:commit=>'Skip', :user=>{:first_name=>'', :last_name=>''}} assigns.should have_callback(:on_post_init_form, :on_init_form_skip, :_on_wizard_skip) response.should redirect_to(:action=>:second) end it "should flag callbacks and redirect to :first page when posting :back to :second page" do post :second, {:commit=>'Back'} assigns.should have_callback(:on_post_second_form, :on_second_form_back, :_on_wizard_back) response.should redirect_to(:action=>:init) end it "should flag callbacks and redirect to :canceled page when posting cancel to second page" do post :second, {:commit=>'Cancel'} assigns.should have_callback(:on_post_second_form, :on_second_form_cancel, :_on_wizard_cancel) response.should redirect_to(:controller=>:main, :action=>:canceled) end it "should flag callbacks and redirect to :completed page when posting finish to the finish page" do post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}} assigns.should have_callback(:on_post_finish_form, :on_finish_form_finish, :_on_wizard_finish) response.should redirect_to(:controller=>:main, :action=>:finished) end end #module TestVariables # def init_page; "init"; end # def second_page; "second"; end # def third_page; "third"; end # def finish_page; "finish"; end # def blank_error; "*can't be blank"; end # def back_button; "back"; end # def next_button; "next"; end # def skip_button; "skip"; end # def finish_button; "finish"; end # def cancel_button; "cancel"; end # def field_first_name; "john"; end # def field_last_name; "doe"; end # def field_age; 30; end # def field_programmer; true; end # def field_status; "active"; end # def field_gender; "male"; end # def field_password; "password"; end # def field_password_confirmation; field_password; end # def field_username; "johndoe"; end # def index_page_path; '/callbacks/index'; end # def finish_page_path; '/callbacks/finish'; end # def second_page_path; '/callbacks/second'; end # def third_page_path; '/callbacks/third'; end # def init_page_path; '/callbacks/init'; end # def main_finished_path; '/main/finished'; end # def main_canceled_path; '/main/canceled'; end #end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/controllers/callbacks2_spec.rb
spec/controllers/callbacks2_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' #require File.dirname(__FILE__) + '/../../app/controllers/callbacks_module' describe Callbacks2Controller do it "should redirect when getting the init form" do get :init response.should redirect_to('/main/index#on_get_init_form') end it "should raise CallbackError when posting to :second form" do lambda { post :second }.should raise_error(Wizardly::CallbackError) end it "should redirect when posting next to the init page with empty fields" do post :init, {:next=>'Next'} response.should redirect_to('/main/index#on_invalid_init_form') end it "should redirect when posting next to the init page with valid fields" do post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}} response.should redirect_to('/main/index#on_init_form_next') end it "should redirect when posting skip to init page" do post :init, {:commit=>'Skip'} response.should redirect_to('/main/index#on_init_form_skip') end it "should redirect when posting :back to init page" do post :init, {:commit=>'Back'} response.should redirect_to('/main/index#on_init_form_back') end it "should redirect when posting cancel to init page" do post :init, {:commit=>'Cancel'} response.should redirect_to('/main/index#on_init_form_cancel') end it "should redirect when posting finish to the finish page" do post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}} response.should redirect_to('/main/index#on_finish_form_finish') end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/controllers/callbacks3_spec.rb
spec/controllers/callbacks3_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' describe Callbacks3Controller do it "should redirect when getting all forms" do get :init response.should redirect_to('/main/index#on_get_all') get :second response.should redirect_to('/main/index#on_get_all') get :finish response.should redirect_to('/main/index#on_get_all') end it "should set the @on_post_init_form when posting to init form" do post :init assigns[:on_post_init_form].should == true end it "should raise CallbackError when posting to :second form" do lambda { post :second }.should raise_error(Wizardly::CallbackError) end it "should redirect when posting next to the init page with empty fields" do post :init, {:commit=>'Next'} response.should redirect_to('/main/index#on_invalid_init_form') end it "should redirect when posting next to the init page with valid fields" do post :init, {:commit=>'Next', :user=>{:first_name=>'john', :last_name=>'doe'}} response.should redirect_to('/main/index#on_init_form_next') end #skip it "should redirect when posting skip to init and finish page" do post :init, {:commit=>'Skip'} response.should redirect_to('/main/index#on_init_and_finish_form_skip') post :finish, {:commit=>'Skip'} response.should redirect_to('/main/index#on_init_and_finish_form_skip') end #back it "should redirect when posting :back to init, finish page" do post :init, {:commit=>'Back'} response.should redirect_to('/main/index#on_init_and_finish_form_back') post :finish, {:commit=>'Back'} response.should redirect_to('/main/index#on_init_and_finish_form_back') end #cancel it "should redirect when posting cancel to init, finish page" do post :init, {:commit=>'Cancel'} response.should redirect_to('/main/index#on_init_and_finish_form_cancel') post :finish, {:commit=>'Cancel'} response.should redirect_to('/main/index#on_init_and_finish_form_cancel') end it "should redirect when posting finish to the finish page" do post :finish, {:commit=>'Finish', :user=>{:username=>'johndoe', :password=>'password', :password_confirmation=>'password'}} response.should redirect_to('/main/index#on_finish_form_finish') end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/spec/models/user_specd.rb
spec/models/user_specd.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe User do before(:each) do @valid_attributes = { } end it "should create a new instance given valid attributes" do User.create!(@valid_attributes) end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly.rb
lib/wizardly.rb
require 'validation_group' require 'wizardly/action_controller' module Wizardly module ActionController module MacroMethods def wizard_for_model(model, opts={}, &block) include Wizardly::ActionController #check for validation group gem configure_wizard_for_model(model, opts, &block) end alias_method :act_wizardly_for, :wizard_for_model end end end begin ActiveRecord::Base.class_eval do class << self alias_method :wizardly_page, :validation_group end end rescue end ActionController::Base.send(:extend, Wizardly::ActionController::MacroMethods)
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/jeffp-wizardly.rb
lib/jeffp-wizardly.rb
require 'wizardly'
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/validation_group.rb
lib/validation_group.rb
module ValidationGroup module ActiveRecord module ActsMethods # extends ActiveRecord::Base def self.extended(base) # Add class accessor which is shared between all models and stores # validation groups defined for each model base.class_eval do cattr_accessor :validation_group_classes self.validation_group_classes = {} def self.validation_group_order; @validation_group_order; end def self.validation_groups(all_classes = false) return (self.validation_group_classes[self] || {}) unless all_classes klasses = ValidationGroup::Util.current_and_ancestors(self).reverse returning Hash.new do |hash| klasses.each do |klass| hash.merge! self.validation_group_classes[klass] end end end end end def validation_group(name, options={}) self_groups = (self.validation_group_classes[self] ||= {}) self_groups[name.to_sym] = case options[:fields] when Array then options[:fields] when Symbol, String then [options[:fields].to_sym] else [] end # jeffp: capture the declaration order for this class only (no # superclasses) (@validation_group_order ||= []) << name.to_sym unless included_modules.include?(InstanceMethods) # jeffp: added reader for current_validation_fields attr_reader :current_validation_group, :current_validation_fields include InstanceMethods # jeffp: add valid?(group = nil), see definition below alias_method_chain :valid?, :validation_group end end end module InstanceMethods # included in every model which calls validation_group #needs testing # def reset_fields_for_validation_group(group) # group_classes = self.class.validation_group_classes # found = ValidationGroup::Util.current_and_ancestors(self.class).find do |klass| # group_classes[klass] && group_classes[klass].include?(group) # end # if found # group_classes[found][group].each do |field| # self[field] = nil # end # end # end def enable_validation_group(group) # Check if given validation group is defined for current class or one of # its ancestors group_classes = self.class.validation_group_classes found = ValidationGroup::Util.current_and_ancestors(self.class). find do |klass| group_classes[klass] && group_classes[klass].include?(group) end if found @current_validation_group = group # jeffp: capture current fields for performance optimization @current_validation_fields = group_classes[found][group] else raise ArgumentError, "No validation group of name :#{group}" end end def disable_validation_group @current_validation_group = nil # jeffp: delete fields @current_validation_fields = nil end def reject_non_validation_group_errors return unless validation_group_enabled? self.errors.remove_on(@current_validation_fields) end # jeffp: optimizer for someone writing custom :validate method -- no need # to validate fields outside the current validation group note: could also # use in validation modules to improve performance def should_validate?(attribute) !self.validation_group_enabled? || (@current_validation_fields && @current_validation_fields.include?(attribute.to_sym)) end def validation_group_enabled? respond_to?(:current_validation_group) && !current_validation_group.nil? end # eliminates need to use :enable_validation_group before :valid? call -- # nice def valid_with_validation_group?(group=nil) self.enable_validation_group(group) if group valid_without_validation_group? end end module Errors # included in ActiveRecord::Errors def add_with_validation_group(attribute, msg = @@default_error_messages[:invalid], *args, &block) # jeffp: setting @current_validation_fields and use of should_validate? optimizes code add_error = @base.respond_to?(:should_validate?) ? @base.should_validate?(attribute.to_sym) : true add_without_validation_group(attribute, msg, *args, &block) if add_error end def remove_on(attributes) return unless attributes attributes = [attributes] unless attributes.is_a?(Array) @errors.reject!{|k,v| !attributes.include?(k.to_sym)} end def self.included(base) #:nodoc: base.class_eval do alias_method_chain :add, :validation_group end end end end module Util # Return array consisting of current and its superclasses down to and # including base_class. def self.current_and_ancestors(current) returning [] do |klasses| klasses << current root = current.base_class until current == root current = current.superclass klasses << current end end end end end # jeffp: moved from init.rb for gemification purposes -- # require 'validation_group' loads everything now, init.rb requires 'validation_group' only ActiveRecord::Base.send(:extend, ValidationGroup::ActiveRecord::ActsMethods) ActiveRecord::Errors.send :include, ValidationGroup::ActiveRecord::Errors
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard.rb
lib/wizardly/wizard.rb
require 'wizardly/wizard/configuration' module Wizardly class WizardlyError < StandardError; end class ModelNotFoundError < WizardlyError; end class ValidationGroupError < WizardlyError; end class CallbackError < WizardlyError; end class MissingCallbackError < WizardlyError; end class WizardConfigurationError < WizardlyError; end class RedirectNotDefinedError < WizardlyError; end class WizardlyGeneratorError < WizardlyError; end class WizardlyScaffoldError < WizardlyGeneratorError; end class WizardlyControllerGeneratorError < WizardlyGeneratorError; end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/action_controller.rb
lib/wizardly/action_controller.rb
require 'wizardly/wizard' module Wizardly module ActionController def self.included(base) base.extend(ClassMethods) base.class_eval do before_filter :guard_entry class << self attr_reader :wizard_config #note: reader for @wizard_config on the class (not the instance) end hide_action :reset_wizard_session_vars, :wizard_config, :methodize_button_name end end module ClassMethods private def configure_wizard_for_model(model, opts={}, &block) # controller_name = self.name.sub(/Controller$/, '').underscore.to_sym @wizard_config = Wizardly::Wizard::Configuration.create(controller_name, model, opts, &block) # define methods self.class_eval @wizard_config.print_page_action_methods self.class_eval @wizard_config.print_callbacks self.class_eval @wizard_config.print_helpers self.class_eval @wizard_config.print_callback_macros end end # instance methods for controller public def wizard_config; self.class.wizard_config; end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false