aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)Author
2017-06-15ReferentialDecorator: Handle non-`Link` buttonsTeddy Wing
Referentials#show has a button "Purger" that isn't a link. Instead, it's a `<button>` element that opens a modal. Previously, we only knew how to put `Link`s in the `#action_links`, and only these could then be rendered in the header bar as buttons. This change allows us to accept non-Link objects. Since the button is rather simple, I decided to create a simple `HTMLElement` class to represent it and output it in the resulting HTML. The class uses the `#content_tag` `ActionView` helper to render the final HTML. Update "referentials/show.html.slim" to output the button correctly in addition to the normal links. Update `TableBuilderHelper#build_links` to not add anything that's not a `Link` to the gear menu. This allows us to display the "Purger" button on the Referentials#show page but not in the table on Workbenches#show. Refs #3479
2017-06-15Link: Change :name & :content into a single property :contentTeddy Wing
The only difference between :name and :content was that :name contained a string and :content contained HTML. But they're really the same thing. Thus it makes much more sense to combine those into a single property that means both, and handles content regardless of type. Refs #3479
2017-06-15TableBuilder: Make destroy link in gear menu render correctlyTeddy Wing
Previously we weren't correctly outputting the proper HTML to get the :delete link rendering correctly with the icon and text. It should show: [TRASH CAN ICON] Supprimer but instead was showing the href. To get this working, I added a `@content` attribute to `Link`. This allows us to optionally specify non-text content to display in the link. We then have delete-link-specific handling when rendering the gear menu's HTML. In that particular case, the `<li>` needs to have a 'delete-action' class in order for the styling to work properly. Created a new `destroy_link` helper method to allow us to reuse the destroy link content in the header bar. TODO: Collect Link#content and Link#name into the same property. TODO: Rename `#destroy_link` to `#destroy_link_content` Refs #3479
2017-06-15TableBuilder;Link: Remove default `:get` for HTTP methodTeddy Wing
Don't set links as `method: :get` by default. This shows up as: link_to _, _, method: :get If we set the method to `nil` instead, we don't get a `data-method="get"` attribute in our HTML output. Instead, we get no `data-method` attribute, which is a lot better and cleaner. I had originally used `:get` as a default because I wanted to generalise links and certain ones we create need `:delete` or `:put` methods. I figured, since we're always going to be passing `method:` to `link_to`, we should have a sane default for that option. However, using `nil` is even better as a default because then we don't get an extra attribute in our HTML at all. Refs #3479
2017-06-12referentials/show.html.slim: Extract header buttons to a decoratorTeddy Wing
Add a new `ReferentialDecorator` that we can use to define the links that appear as buttons in the header of the `/referentials/:id` page. The idea is that these links will take the place of the existing view code and in the view, we'll instead loop over the links provided by the decorator and render them as buttons. I decided to do it this way because there's a requirement that the links in the gear menu in tables show the same links that appear in the header of the page. So the Workbenches#show page would show a table of referentials, and their gear menu links should ostensibly be the same as the header links in the Referentials#show page. My goal was to abstract links, and try to separate them from the presentation layer. Still having trouble with this though. I created a new `Link` class to represent a link. We can then use this in the template to create a `link_to`. It becomes messy, though, when we want to put other elements inside a certain link, as evidenced by the `:delete` link. Don't like how that's done, but still working out the best approach to make it cleaner. Refs #3479
2017-06-12Refs: #3603@4h, hotfixRobert
2017-06-09refs 3604 @12h all tests passRobert
2017-06-08Refs: #3604 @2h checking sequences as defaultsRobert
2017-06-06Refs: #3604; rewriting schema cloner in RubyRobert
2017-06-06Refs: #3604; added tests for cloning with data ⇒ ✓Robert
2017-06-02Merge branch 'master' of github.com:af83/stif-boivRobert
2017-05-31hotfix to adapt referential:create task to newly required attribute ↵Robert
'public_name'
2017-05-29TimeDuration.exceeds_gap?: Fix duration > 24 hours behaviourTeddy Wing
Previously, the `#exceeds_gap?` method would modulo the `later - earlier` duration against 24 hours such that no duration exceeded 24 hours, and the resulting duration being compared was adjusted to fit inside a single day. When we removed the numbers from `exceeds_gap?`, we also removed the modulo operation. I had a feeling that would potentially cause problems, and it turns out it did. Though it still took too much investigation time to realise that the most obvious answer was in fact the correct one. Blame the confusing test failures if I will: Failures: 1) Chouette::VehicleJourney state_update should return errors when validation failed Failure/Error: expect(state['errors'][:vehicle_journey_at_stops].size).to eq 1 NoMethodError: undefined method `[]' for nil:NilClass # ./spec/models/chouette/vehicle_journey_spec.rb:148:in `block (3 levels) in <top (required)>' 2) Chouette::VehicleJourney state_update vehicle_journey_at_stops should return errors when validation failed Failure/Error: expect(item['errors'][:arrival_time].size).to eq 1 NoMethodError: undefined method `[]' for nil:NilClass # ./spec/models/chouette/vehicle_journey_spec.rb:189:in `block (4 levels) in <top (required)>' 3) VehicleJourneyImport.save should not import vehicle_journeys and not create objects when vehicle journey at stops are not in ascendant order Failure/Error: expect(VehicleJourneyImport.new(:route => route, :file => invalid_file_on_vjas_object).save).to be_falsey expected: falsey value got: true # ./spec/models/vehicle_journey_import_spec.rb:90:in `block (3 levels) in <top (required)>' Finished in 4 minutes 20.7 seconds (files took 14.47 seconds to load) 1089 examples, 3 failures, 23 pending Failed examples: rspec ./spec/models/chouette/vehicle_journey_spec.rb:137 # Chouette::VehicleJourney state_update should return errors when validation failed rspec ./spec/models/chouette/vehicle_journey_spec.rb:183 # Chouette::VehicleJourney state_update vehicle_journey_at_stops should return errors when validation failed rspec ./spec/models/vehicle_journey_import_spec.rb:89 # VehicleJourneyImport.save should not import vehicle_journeys and not create objects when vehicle journey at stops are not in ascendant order These three tests failed with my version of `exceeds_gap?`. To correct the failures, add back in the 24-hour adjustment. Put it in a named method that is hopefully clear enough to understand. The second test failure ("vehicle_journey_at_stops should return errors when validation failed") used two times that were the same. I decided to add a test for this because it seemed like an interesting edge case. The test I added didn't fail even for the previous version of `.exceeds_gap?`, but I figure it seems like a useful test anyway. Refs #870
2017-05-29TimeDuration: Add a method comment above `.exceeds_gap?`Teddy Wing
Describe what's going on here to hopefully make it easier to understand. Refs #870
2017-05-29TimeDuration: Use the `duration` argumentTeddy Wing
Instead of hard-coding the duration to compare against, get it from the function argument. This allows us to set different durations at the time the method is called. Also simplify the comparison, getting rid of the math that makes this method much more difficult to read. Refs #870
2017-05-29Create `TimeDuration` module for `#exceeds_gap?` methodTeddy Wing
Put the `exceeds_gap?` method in a new module called `TimeDuration`. This will allow us to use it from both the `Chouette::VehicleJourneyAtStop` class and from the `IncreasingTimeOrderValidator`. Doing this also allows us to test it independently. Haven't yet rewritten the increasing times validator to take advantage of this new method, but adding it now to ensure we don't get an error calling a non-existent method in `VehicleJourneyAtStop`. I changed the signature of the method to take a duration as its first argument. This allows us to set arbitrary durations to compare against and surfaces the duration when reading code where the method is called. Not sure if that's the best approach here, but it seems to make sense for now. Refs #870
2017-05-09minor esthetic correctionRobert
2017-05-03Improve referential:create task. Refs #3291Alban Peignier
* use a single transaction * use by default workbench 1 * use a random line found in workbench lines
2017-05-03Use test env for teaspoon (#mybad). Refs #3275Alban Peignier
2017-05-03Disable teaspoon (#mybad). Refs #3275Alban Peignier
2017-05-03Restore ci:check_security in ci task. Fixes last warnings in GemfileAlban Peignier
2017-05-03Add teaspoon in ci dependencies. Fixes #3275Alban Peignier
2017-05-02more duplicates of Range#intersection removed and range_ext required insteadRobert
2017-05-02duplicate code from models/calendar removed; coherent naming in ↵Robert
Range#intersection
2017-04-28Add seasonal to linesXinhui
Refs #3077
2017-04-28Merge branch 'master' of github.com:af83/stif-boivRobert
2017-04-28Sync reflex Quay description to stop_area :commentXinhui
Refs #3089
2017-04-27more information into output of rake referential:createjpl
2017-04-26Fixes referential:create task. Refs #2975Alban Peignier
* define default start_date and end_date * associate VehicleJourneyAtStops to VehicleJourney * associate VehicleJourney to TimeTables * add a message to display which Referential is created * mark created Referential as ready
2017-04-18clone_schema fixed -> lib/sql/clone_schema.sql; ↵RobertDober
lib/af83/stored_procedures.rb for sql stored procedure management; Refs #2864
2017-04-11Disable seed execution in deploy. Refs #3017Alban Peignier
2017-04-11Some tests -> pending, other tests fixed; Refs #2070RobertDober
2017-03-30Ignore invalid date in ActiveAttr. Refs #2997Alban Peignier
2017-03-29Refs #2975 : Rake task to create a Referential and its dataVlatka Pavisic
2017-03-22Refactoring reflex area_type conditionXinhui
Refs #2789
2017-03-09Sync Reflex ObjectStatus into StopArea stif_typeXinhui
Refs #2737
2017-02-18Support multi parameter in ReferentialMetadata::Period to fix begin/end ↵Alban Peignier
dates. Refs #2621
2017-02-14Refs #2596 : Fix tests pt. 2Vlatka Pavisic
2017-02-03Chouette::Line mport secondary_companiesXinhui
Refs #2490
2017-01-25Store long lat for StopArea & AccessPointXinhui
2017-01-24Fix area_type of Quay is now based on OBJET_QUALIFIER valueXinhui
Refs #2451
2017-01-04Merge masterVlatka Pavisic
2017-01-03Merge enum_stop_area_area_type into masterXinhui
2016-12-30Refs #2262 Refs #2263 Refs #2264 Refs #2265 : Calendars 80% doneVlatka Pavisic
2016-12-15Rename asset for new area_typeXinhui
2016-11-29Refactoring stop_area area_type as enumerizeXinhui
2016-11-28Tmp fix AccessPoints IsEntry:false IsExit:falseXinhui
Refs #2089
2016-11-28Tmp fix AccessPoints IsEntry:false IsExit:falseXinhui
Refs #2089
2016-11-28Refs #2068: remove ci:check_security, in order to allow buildsjpl
2016-11-27Add ci:check_security in ci task. Refs #2068Alban Peignier